QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153499#1336. Non-Trivial Common DivisorrmqWA 2ms3712kbC++141.0kb2023-08-30 08:32:022023-08-30 08:32:02

Judging History

你现在查看的是最新测评结果

  • [2023-08-30 08:32:02]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3712kb
  • [2023-08-30 08:32:02]
  • 提交

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
*/


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3668kb

input:

6
1
2
3
4
5
6

output:

12

result:

ok answer is '12'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

3
173
1733
111733

output:

111733

result:

ok answer is '111733'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

4
1
1
1
1

output:

0

result:

ok answer is '0'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3572kb

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: 3712kb

input:

1
999999999

output:

999999999

result:

ok answer is '999999999'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3592kb

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: 3692kb

input:

3
12
3
19

output:

19

result:

ok answer is '19'

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3712kb

input:

10
20
20
9
10
20
5
1
19
20
4

output:

94

result:

wrong answer expected '95', found '94'