ZCPUZZLE

7319

println好好学习
SKG_G

hao1ngkK
zhengnengliang
sqge

ikaqiu
TinyDolphin

Lims
Lims
Oier12138
M._3
yyhhmm
RyanMoriarty

ZCPUZZLE
8个月前
#include <bits/stdc++.h>
using namespace std;
int a[101];
int main() {
int n,i,c=0;
cin>>n;
for(i=1; i<=n; i++)cin>>a[i];
sort(a+1,a+1+n);
for(i=1; i<=n; i++)
if(a[i]!=0&&a[i]!=a[i-1])c++;
cout<<c;
}


ZCPUZZLE
10个月前
#include <iostream>
#include <algorithm>

using namespace std;
const int N = 1e6+10;
int a[N], k, n, m,s;

int main()
{
cin >> n >> k;
for (int i = 1; i <= n; i ++ )
{
cin >> m;
a[i] = a[i - 1] + m;
}

for (int i = 1; i <= n - k; i ++ )
{
s = max(s, a[i + k] - a[i - 1]);
}
cout << s << endl;
return 0;
}


ZCPUZZLE
2021-11-13 21:05
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

bool check(int c, int d, int i, int j)
{
int x = abs(c - i), y = abs(d - j);
return x == 1 && y == 2 || x == 2 && y == 1;
}

int main()
{
char s1[3], s2[3];
int a, b, c, d;

cin >> s1 >> s2;
a = s1[0] - 'a', b = s1[1] - '1';
c = s2[0] - 'a', d = s2[1] - '1';

int res = 0;

for (int i = 0; i < 8; i ++ )
for (int j = 0; j < 8; j ++ )
{
if(i == a && j == b || i == c && j == d) continue;
if(i == a || j == b) continue;
if(check(c, d, i, j) || check(a, b, i ,j)) continue;
res ++ ;
}

cout << res << endl;

return 0;
}


ZCPUZZLE
2021-11-13 20:47
#include <iostream>

using namespace std;

int n, maxa, b;
int a[10010];

int main()
{
cin >> n;
for (int i = 1; i <= n; i ++ )
{
cin >> a[i];
maxa = max(maxa, a[i]);
b = a[i];
}
cout << (maxa ^ b) << endl;
return 0;
}


ZCPUZZLE
2021-11-13 20:40
#include <iostream>

using namespace std;

int n;

int main()
{
cin >> n;
for (int i = 0; i < n - 1; i ++ )
if(i % 2 == 1) cout << "I love that ";
else cout << "I hate that ";

if(n % 2 == 0) cout << "I love it ";
else cout << "I hate it ";

return 0;
}


ZCPUZZLE
2021-11-03 01:24
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int n, res = -0x3f3f3f3f;

int main()
{
cin >> n;

while (n -- )
{
int x;
cin >> x;
if(sqrt(x * 1.0000) != int(sqrt(x))) res = max(res, x);
}

cout << res << endl;

return 0;
}


ZCPUZZLE
2021-10-22 17:55

## 一道贪心题 思路很重要

#include <iostream>
#include <algorithm>

#define LL long long

using namespace std;

const int N = 1000010;

int a[N], p[N], xz, n;
LL xb, res;

int main()
{
cin >> n;

for (int i = 1; i <= n; i ++ )
{
cin >> a[i];
xb += a[i];
}

xb /= n;

p[1] = 0;
for (int i = 1; i <= n; i ++ )
{
p[i] = p[i - 1] + xb - a[i];
}

sort(p + 1, p + n + 1);

if(n % 2 == 0) xz = (p[n / 2] + p[n / 2 + 1]) / 2;
else xz = p[n / 2];

for (int i = 1; i <= n; i ++ )
res += abs(xz - p[i]);

cout << res << endl;

return 0;
}


ZCPUZZLE
2021-10-22 16:54
orz ←这是小孩 OTZ ←这是大人 OTL ←这是完全失落 or2 ←这是屁股特别翘的 or2=3 ←这是放了个屁的 Or2 ←这是头大身体小的翘屁股 Or? ←这也是头大身体小的翘屁股 orZ ←这是下半身肥大 OTz ←这是举重选手吧 ○rz ←这是大头 ●rz ←这是黑人头先生 Xrz ←这是刚被爆头完 6rz ←这是魔人普乌 On ←这是婴儿 crz ←这是机车骑士 囧rz ←这是念“炯” 崮rz ←这是囧国国王 莔rz ←这是囧国皇后 商rz ←这是戴斗笠的囧 st冏 ←楼上的他老婆吗 sto ←换一边跪 org ←女娲/美人鱼 曾rz ←假面超人 益r2 ←闭起眼睛，很痛苦且咬牙切齿的脸；另一说法为无敌铁金刚 ★rz ←武藤游戏 口rz ← 豆腐先生 __Drz ← 爆脑浆 prz ← 长发垂地的orz @rz ← 呆滞垂地的orz srQ ← 换一边并舔地的orz 圙rz ← 这是老人家的面 胎rz ← 这个是没眼睛的 囜rz ← 没有眼和口的 国rz ← 这是歪咀的 国rz ← 这是无话可说的 苉rz ← 这是女的 Ora ←衍伸用法，不过脚是跪着状态。 or7 ←尖屁股囧兴←乌龟 Oroz ←这是有小腹 Orz~ ←这是赛亚人版orz :◎:rz ←这是张大嘴巴嚎啕大哭的orz oΩ: ←背部隆起的可怜orz

ZCPUZZLE
2021-10-22 16:22

## RMQ算法 类似于动态规划

#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

const int N = 200010, M = 18;

int n, m;
int w[N];
int f[N][M];

void init()
{
for (int j = 0; j < M; j ++ )
for (int i = 1; i + (1 << j) - 1 <= n; i ++ )
if(!j) f[i][j] = w[i];
else f[i][j] = max(f[i][j - 1], f[i + (1 << j - 1)][j - 1]);
}

int query(int l, int r)
{
int len = r - l + 1;
int k = log(len) / log(2);//换底公式

return max(f[l][k], f[r - (1 << k) + 1][k]);
}

int main()
{
cin >> n;
for (int i = 1; i <= n; i ++ ) cin >> w[i];

init();

cin >> m;

while (m -- )
{
int l, r;
cin >> l >> r;
cout << query(l, r) << endl;
}
return 0;
}


ZCPUZZLE
2021-10-22 13:27
#include <iostream>

using namespace std;

const int mod = 9901;

int quick_power(int a, int k)
{
int res = 1;
a %= mod;
while (k)
{
if(k & 1) res = res * a % mod;
a = a * a % mod;
k >>= 1;
}
return res;
}

int sum(int p, int k)
{
if(k == 1) return 1;
if(k % 2 == 0) return (1 + quick_power(p, k / 2)) * sum(p, k / 2) % mod;
return (sum(p, k - 1) + quick_power(p, k - 1)) % mod;
}

int main()
{
int a, b;
cin >> a >> b;
int res = 1;

for (int i = 2; i * i <= a; i ++ )
if(a % i == 0)
{
int s = 0;
while (a % i == 0)
{
a /= i, s ++ ;
}
res = res * sum(i, b * s + 1) % mod;
}

if(a > 1) res = res * sum(a, b + 1) % mod;
if(a == 0) res = 0;

cout << res << endl;

return 0;
}