QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#153500 | #1336. Non-Trivial Common Divisor | rmq | AC ✓ | 12ms | 4100kb | C++14 | 1.0kb | 2023-08-30 08:33:25 | 2023-08-30 08:33:26 |
Judging History
answer
#include"bits/stdc++.h"
#define int long long
using namespace std;
int read() {
int x = 0, fff = 1;
char c;
while ((c = getchar()) < '0' || c > '9')
if (c == '-')
fff = -1;
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
return x * fff;
}
const double eps = 1e-6;
const int N = 2e3 + 5;
const int M = 100 + 5;
const int V = 10;
const int mod = 998244353;
const int bse = 998244353;
const int inf = 1e9;
const double pi = acos(-1);
int n;
int a[N];
unordered_map<int, int>hsh;
int ans;
signed main() {
// freopen("1.in", "r", stdin);
n = read();
for(int i = 1; i <= n; i++) {
int x;
x = read();
int tmp = x;
for(int i = 2; i <= sqrt(x); i++) {
if(i * i == x) {
hsh[i] += tmp;
ans = max(ans, hsh[i]);
break;
}
if(x % i == 0) {
while(x % i == 0) x /= i;
hsh[i] += tmp;
ans = max(ans, hsh[i]);
}
}
if(x != 1) hsh[x] += tmp;
ans = max(ans, hsh[x]);
}
printf("%lld\n", ans);
return 0;
}
/*
5 2
5 5 5 5 5
2 2
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4052kb
input:
6 1 2 3 4 5 6
output:
12
result:
ok answer is '12'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
3 173 1733 111733
output:
111733
result:
ok answer is '111733'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
4 1 1 1 1
output:
0
result:
ok answer is '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
10 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999
output:
9999999990
result:
ok answer is '9999999990'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
1 999999999
output:
999999999
result:
ok answer is '999999999'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
10 28851 8842 9535 2311 25337 26467 12720 10561 8892 6435
output:
56898
result:
ok answer is '56898'
Test #7:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
3 12 3 19
output:
19
result:
ok answer is '19'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
10 20 20 9 10 20 5 1 19 20 4
output:
95
result:
ok answer is '95'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
5 3 13 2 11 4
output:
13
result:
ok answer is '13'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
2 9 12
output:
21
result:
ok answer is '21'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
2 12 18
output:
30
result:
ok answer is '30'
Test #12:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
8 19 1 17 17 19 13 11 9
output:
38
result:
ok answer is '38'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
4 12 16 9 6
output:
34
result:
ok answer is '34'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3756kb
input:
7 15 18 1 16 9 12 6
output:
60
result:
ok answer is '60'
Test #15:
score: 0
Accepted
time: 1ms
memory: 4100kb
input:
3 9 2 19
output:
19
result:
ok answer is '19'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
7 14 7 8 7 8 5 14
output:
44
result:
ok answer is '44'
Test #17:
score: 0
Accepted
time: 11ms
memory: 4064kb
input:
957 522627804 400792198 220572477 772420713 949106732 867088911 850851737 541599109 310148807 481974581 792195677 311938108 460640026 450255324 569921314 278219751 888194392 422277480 438560464 86173934 738154829 149378290 781306443 290126418 910494332 432352620 69931343 257768620 296685964 11124460...
output:
247048725634
result:
ok answer is '247048725634'
Test #18:
score: 0
Accepted
time: 3ms
memory: 3760kb
input:
248 833462177 832360338 331481268 949654765 60211903 733156083 686736689 637046496 462060457 585883635 985895710 916425502 484795806 72643467 980078824 930701517 448897152 127560093 383579681 472399291 143262194 466638782 304520312 337422898 165892865 435647198 60059210 316088498 714601768 479501870...
output:
67252731850
result:
ok answer is '67252731850'
Test #19:
score: 0
Accepted
time: 6ms
memory: 4064kb
input:
487 94076248 879311282 41528500 766221230 119283462 763277566 363751168 567423114 570994040 991593348 843192233 442072572 231715458 507143547 819331915 345647451 235852093 829423535 876403806 312526674 872612073 180408179 60666755 950692980 118541573 368699384 673578612 140704141 94039184 315794615 ...
output:
133032997690
result:
ok answer is '133032997690'
Test #20:
score: 0
Accepted
time: 4ms
memory: 3776kb
input:
586 448499010 455964638 739627577 182129295 503908902 692114260 404913440 742125008 803425426 149995751 419269452 948627983 879703915 758357816 627539127 914459668 375443871 517246667 798370334 359746602 261807514 647642136 61526156 330220598 533748087 464662202 348920039 699440429 373634359 9779634...
output:
152932375346
result:
ok answer is '152932375346'
Test #21:
score: 0
Accepted
time: 10ms
memory: 3784kb
input:
803 887827636 485158477 672450671 26581057 943349778 866307211 834230089 380252787 658518626 546885929 743146732 959138287 479560584 200763449 942864414 281969323 384263257 539260471 599180236 343514194 357294483 158120388 687878933 688866782 797692182 389801547 828460307 984159157 77758148 16783760...
output:
204028435234
result:
ok answer is '204028435234'
Test #22:
score: 0
Accepted
time: 4ms
memory: 3860kb
input:
297 373250397 442094344 450753516 451859082 88082845 241368893 158976836 233504878 922528460 448371970 80510543 700423628 306807206 125820353 872175129 732106068 958871225 972627246 364629895 99103372 91604726 869744106 341029031 434024821 700170115 103722282 975821825 599802145 783425150 427313145 ...
output:
78104160660
result:
ok answer is '78104160660'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
203 590924798 827866650 811940664 186640469 382831288 259716737 129158960 319546863 281612866 490756540 847479042 683050962 53494611 95169425 540471717 156374141 903454702 654306078 152635055 785485924 31908828 874428782 783161816 552297343 643599955 663310316 84486148 142951449 499579736 312820582 ...
output:
57670921422
result:
ok answer is '57670921422'
Test #24:
score: 0
Accepted
time: 6ms
memory: 3792kb
input:
778 65697236 154196615 420824653 262431245 876954209 981184655 733651569 389218337 783527042 612621878 132329316 454038572 217168149 918142154 675222859 867167565 731753874 627522636 289294808 833771308 214402394 990398467 699341183 435783108 3058290 470341635 835784885 331141045 671846735 690834975...
output:
187671706090
result:
ok answer is '187671706090'
Test #25:
score: 0
Accepted
time: 4ms
memory: 3704kb
input:
310 402947561 776186710 239837125 97164069 899443944 223227689 590571426 130392722 841663206 965966377 193353759 431902972 612345634 258623421 373086008 721813995 208588977 339010257 643842773 115310980 307097677 311229138 310232402 871962788 304197774 649475413 899649951 169252321 666939549 7576327...
output:
70850156656
result:
ok answer is '70850156656'
Test #26:
score: 0
Accepted
time: 3ms
memory: 3756kb
input:
173 44335202 624245067 232116255 64066024 754495793 839942658 365425758 471005472 752804898 192715339 834489322 423218279 392916910 949591732 43355647 427177169 176971997 899893148 150140374 335606612 118461600 438659395 396105045 522274729 496057306 998315626 735593523 416367689 248162381 522111872...
output:
48718840966
result:
ok answer is '48718840966'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
1 1
output:
0
result:
ok answer is '0'
Test #28:
score: 0
Accepted
time: 0ms
memory: 4100kb
input:
1 999999937
output:
999999937
result:
ok answer is '999999937'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
6 100000000 100000000 100000000 100000000 499999993 999999986
output:
1499999979
result:
ok answer is '1499999979'
Test #30:
score: 0
Accepted
time: 1ms
memory: 3804kb
input:
1000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
output:
1000000000000
result:
ok answer is '1000000000000'
Test #31:
score: 0
Accepted
time: 12ms
memory: 3804kb
input:
1000 1000000000 999999998 999999996 999999994 999999992 999999990 999999988 999999986 999999984 999999982 999999980 999999978 999999976 999999974 999999972 999999970 999999968 999999966 999999964 999999962 999999960 999999958 999999956 999999954 999999952 999999950 999999948 999999946 999999944 9999...
output:
999999001000
result:
ok answer is '999999001000'
Test #32:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
0
result:
ok answer is '0'