QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#153498 | #1336. Non-Trivial Common Divisor | rmq | WA | 1ms | 3700kb | C++14 | 1.0kb | 2023-08-30 08:31:31 | 2023-08-30 08:31:32 |
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]);
}
}
hsh[x] += tmp;
ans = max(ans, hsh[x]);
}
printf("%lld\n", ans);
return 0;
}
/*
5 2
5 5 5 5 5
2 2
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
input:
6 1 2 3 4 5 6
output:
12
result:
ok answer is '12'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
3 173 1733 111733
output:
111733
result:
ok answer is '111733'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3700kb
input:
4 1 1 1 1
output:
4
result:
wrong answer expected '0', found '4'