QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153498#1336. Non-Trivial Common DivisorrmqWA 1ms3700kbC++141.0kb2023-08-30 08:31:312023-08-30 08:31:32

Judging History

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

  • [2023-08-30 08:31:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2023-08-30 08:31:31]
  • 提交

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'