QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674070#9248. An Easy Math Problemwoodie_0064#WA 6ms8328kbC++20873b2024-10-25 13:37:122024-10-25 13:37:12

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:37:12]
  • Judged
  • Verdict: WA
  • Time: 6ms
  • Memory: 8328kb
  • [2024-10-25 13:37:12]
  • 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 and (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: 0
Wrong Answer
time: 6ms
memory: 8328kb

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
2
2
2
2
5
2
4
2
5

result:

wrong answer 4th lines differ - expected: '3', found: '2'