ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204071 | #2861. 取模 | tkswls | 100 | 1102ms | 24688kb | C++ | 601b | 2024-04-07 08:13:23 | 2024-04-07 12:03:23 |
answer
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize(2)
using namespace std;
int n, a[1000006], sum[1000006], b[10000066], ans;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i], sum[a[i]]++, ans += a[i];
for (int i = 1; i <= 1000000; i++) {
if (sum[i]) {
for (int j = i; j <= 1000000; j += i) {
b[j] += i * sum[i];
}
}
}
for (int j = 1000000 - 1; j >= 1; j--) sum[j] += sum[j + 1];
ans *= n;
for (int i = 1; i <= 1000000; i++) {
ans -= b[i] * sum[i];
}
cout << ans;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 21ms
memory: 16884kb
input:
1000 562 554 492 436 89 680 616 116 641 180 560 655 199 353 457 673 348 463 421 945 10 680 764 429 9...
output:
224824489
result:
ok single line: '224824489'
Test #2:
score: 10
Accepted
time: 26ms
memory: 16884kb
input:
1000 796 814 101 939 438 725 173 275 472 989 891 160 617 6 888 26 180 80 481 838 893 109 209 999 344...
output:
219299789
result:
ok single line: '219299789'
Test #3:
score: 10
Accepted
time: 24ms
memory: 16884kb
input:
1000 561 47 21 409 250 935 699 759 224 538 29 140 641 219 677 36 942 352 86 795 718 797 834 185 799 ...
output:
222992172
result:
ok single line: '222992172'
Test #4:
score: 10
Accepted
time: 144ms
memory: 24688kb
input:
1000000 62 66 755 636 346 137 850 437 56 713 933 746 693 970 893 833 76 381 393 735 84 470 468 893 9...
output:
225675483984380
result:
ok single line: '225675483984380'
Test #5:
score: 10
Accepted
time: 84ms
memory: 24688kb
input:
1000000 10 507 413 110 624 746 474 522 770 888 673 371 944 585 501 295 117 726 416 176 704 622 424 2...
output:
226247988105012
result:
ok single line: '226247988105012'
Test #6:
score: 10
Accepted
time: 144ms
memory: 24688kb
input:
1000000 900 190 601 261 441 733 137 704 323 3 252 289 799 35 771 689 95 882 715 79 206 554 622 578 4...
output:
225836509823663
result:
ok single line: '225836509823663'
Test #7:
score: 10
Accepted
time: 249ms
memory: 24688kb
input:
1000000 354178 328124 966233 183601 212361 504913 290778 605023 523560 57645 799260 569147 201887 99...
output:
225982215578396631
result:
ok single line: '225982215578396631'
Test #8:
score: 10
Accepted
time: 150ms
memory: 24684kb
input:
1000000 579897 417434 709462 662211 96691 710418 426163 574275 159350 67212 936180 648837 668496 878...
output:
225672032772550634
result:
ok single line: '225672032772550634'
Test #9:
score: 10
Accepted
time: 115ms
memory: 24684kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34...
output:
225844249726680045
result:
ok single line: '225844249726680045'
Test #10:
score: 10
Accepted
time: 145ms
memory: 24684kb
input:
1000000 805254 533213 511332 81316 644919 818855 33277 608430 296450 808114 622007 217786 747179 476...
output:
225794156503959514
result:
ok single line: '225794156503959514'
Extra Test:
score: 0
Extra Test Passed