用户输出
12
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#69264 | #1261. 数字删除 | Accepted | 100 | 348 ms | 1012 K | C++ 11 / 946 B | Shirost | 2022-05-13 11:11:30 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
;
int gcd(int x, int y) {
if (!y)
return x;
return gcd(y, x % y);
}
int n;
int a[N], b[N];
map<int, int> mp;
vector<int> p;
int isprime[N], prime[N], cnt;
void init() {
for (int i = 2; i < N; ++i)
if (!isprime[i]) {
prime[++cnt] = i;
for (int j = i + i; j < N; j += i) isprime[j] = 1;
}
}
int main() {
init();
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), b[i] = a[i];
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= cnt && prime[j] <= a[i]; ++j)
if (a[i] % prime[j] == 0) {
if (!mp[prime[j]])
mp[prime[j]] = 1, p.push_back(prime[j]);
while (a[i] % prime[j] == 0) a[i] /= prime[j];
}
if (a[i] != 1)
if (!mp[a[i]])
mp[a[i]] = 1, p.push_back(a[i]);
}
long long ans = 0;
for (int i = 0; i < p.size(); ++i) {
int x = p[i];
long long res = 0;
// printf("x=%d\n",x);
for (int j = 1; j <= n; ++j)
if (b[j] % x == 0)
res += b[j];
ans = max(ans, res);
}
printf("%lld\n", ans);
return 0;
}
10
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
9999999
<3 bytes omitted>
用户输出
9999999990
系统信息
Exited with return code 0
用户输出
56898
系统信息
Exited with return code 0
957
522627804
400792198
220572477
772420713
949106732
867088911
850851737
541599109
310148807
481974
<9352 bytes omitted>
用户输出
247048725634
系统信息
Exited with return code 0
248
833462177
832360338
331481268
949654765
60211903
733156083
686736689
637046496
462060457
5858836
<2361 bytes omitted>
用户输出
67252731850
系统信息
Exited with return code 0
487
94076248
879311282
41528500
766221230
119283462
763277566
363751168
567423114
570994040
99159334
<4721 bytes omitted>
用户输出
133032997690
系统信息
Exited with return code 0
586
448499010
455964638
739627577
182129295
503908902
692114260
404913440
742125008
803425426
149995
<5716 bytes omitted>
用户输出
152932375346
系统信息
Exited with return code 0
803
887827636
485158477
672450671
26581057
943349778
866307211
834230089
380252787
658518626
5468859
<7838 bytes omitted>
用户输出
204028435234
系统信息
Exited with return code 0
297
373250397
442094344
450753516
451859082
88082845
241368893
158976836
233504878
922528460
4483719
<2835 bytes omitted>
用户输出
78104160660
系统信息
Exited with return code 0
203
590924798
827866650
811940664
186640469
382831288
259716737
129158960
319546863
281612866
490756
<1918 bytes omitted>
用户输出
57670921422
系统信息
Exited with return code 0
778
65697236
154196615
420824653
262431245
876954209
981184655
733651569
389218337
783527042
6126218
<7592 bytes omitted>
用户输出
187671706090
系统信息
Exited with return code 0
310
402947561
776186710
239837125
97164069
899443944
223227689
590571426
130392722
841663206
9659663
<2970 bytes omitted>
用户输出
70850156656
系统信息
Exited with return code 0
173
44335202
624245067
232116255
64066024
754495793
839942658
365425758
471005472
752804898
19271533
<1619 bytes omitted>
用户输出
48718840966
系统信息
Exited with return code 0
用户输出
1499999979
系统信息
Exited with return code 0
1000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000
<10905 bytes omitted>
用户输出
1000000000000
系统信息
Exited with return code 0
1000
1000000000
999999998
999999996
999999994
999999992
999999990
999999988
999999986
999999984
9999
<9906 bytes omitted>
用户输出
999999001000
系统信息
Exited with return code 0