QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#616752 | #8637. 搬砖 | A_big_rubbish | 0 | 0ms | 0kb | C++14 | 1.5kb | 2024-10-06 11:09:12 | 2024-10-06 11:09:12 |
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int n, maxn, a[1000001], cishu[1000001], b[1000001], ans, cnt, tot;
signed main()
{
freopen("bricks.in", "r", stdin);
freopen("bricks.out", "w", stdout);
n = read();
for (int i = 1; i <= n; i++)
{
a[i] = read();
cishu[a[i]]++;
maxn = max(maxn, a[i]);
}
for (int i = 1; i <= maxn; i++)
{
cishu[i] += cishu[i - 1];
}
for (int i = 1; i <= maxn; i++)
{
tot = maxn / i;
for (int j = 1; j <= tot; j++)
{
b[j] = cishu[min(i * (j + 1) - 1, maxn)] - cishu[i * j - 1];
}
cnt = 0;
for (int j = 1; j <= tot; j++)
{
cnt += (b[j] & 1);
}
if (cnt == 1)
{
if (b[1] & 1)
ans += b[1];
}
if (cnt == 2)
{
for (int j = 2; j <= tot; j++)
{
if ((b[j] & 1) && (b[j - 1] & 1))
{
ans += b[j];
}
}
}
}
printf("%lld", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Dangerous Syscalls
Test #1:
score: 0
Dangerous Syscalls
input:
19 49 87 55 72 26 28 61 89 3 74 68 5 35 38 29 51 43 50 99
output:
result:
Subtask #2:
score: 0
Dangerous Syscalls
Test #21:
score: 0
Dangerous Syscalls
input:
199999 847249 186487 367355 618072 937226 591328 776261 362189 96203 363974 349368 378905 615535 753238 551029 549551 648843 257850 897199 780171 34956 529292 138489 164016 983045 678158 447625 770688 359626 620193 47041 723226 806679 414396 857650 260257 522075 633910 622445 618277 514235 488164 99...