QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674069#9248. An Easy Math Problemwoodie_0064#RE 7ms9192kbC++20872b2024-10-25 13:36:222024-10-25 13:36:23

Judging History

This is the latest submission verdict.

  • [2024-10-31 22:36:43]
  • hack成功,自动添加数据
  • (/hack/1098)
  • [2024-10-31 22:13:58]
  • hack成功,自动添加数据
  • (/hack/1096)
  • [2024-10-31 22:00:43]
  • hack成功,自动添加数据
  • (/hack/1095)
  • [2024-10-25 13:36:23]
  • Judged
  • Verdict: RE
  • Time: 7ms
  • Memory: 9192kb
  • [2024-10-25 13:36:22]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
using i64 = long long;
const int N = 1e6 + 3, M = N;
int T;
i64 n, num, m;
int v[N], p[N];

void primes(int n){
	memset(v, 0, sizeof(v));
	m = 0;
	for(int i = 2; i <= n; ++i){
		if(v[i] == 0){
			v[i] = i; p[++m] = i;
		}
		for(int j = 0; j <= m; ++j){
			if(p[j] > v[i] or p[j] > n / i) break;
			v[i * p[j]] = p[j];
		}
	}
}

void work(){
	cin >> n;
	i64 ans = 1;
	for(int i = 1; n > 1 or (i64)p[i] * p[i] < n; ++i){
		int cnt = 0;
		while(n % p[i] == 0)
			cnt++, n /= p[i];
		ans *= (2 * cnt + 1); 
	}
	if(n > 1){
		ans *= 3;
	}
	cout << ans / 2 + 1 << "\n";
}


int main(){
//	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	primes(N-2);
	cin >> T;
	while(T--){
		work();
	}	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 8624kb

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
2
2
3
2
5
2
4
3
5

result:

ok 10 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 9192kb

input:

2000
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
6469693230
646969323...

output:

29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
...

result:

ok 2000 lines

Test #3:

score: -100
Runtime Error

input:

2000
1763047095
79735483
1016286871
2864801397
2327774116
2668010360
3469893354
3634459021
1613699068
781737219
574741575
2763134701
1458502604
1822260248
2281150332
2924219311
2493931196
3735904708
158802001
2006921221
729928782
1974841034
727412600
2873393292
1291087179
2741607663
1893408215
29827...

output:


result: