QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762783#9248. An Easy Math ProblemmobbbWA 456ms7724kbC++20985b2024-11-19 16:38:012024-11-19 16:38:09

Judging History

This is the latest submission verdict.

  • [2024-11-19 16:38:09]
  • Judged
  • Verdict: WA
  • Time: 456ms
  • Memory: 7724kb
  • [2024-11-19 16:38:01]
  • Submitted

answer

#include <bits/stdc++.h>

#define ll long long

std::vector<int> minp, primes;
void sieve(int n) {
    minp.assign(n + 1, 0);
    primes.clear();
    for (int i = 2; i <= n; i++) {
        if (minp[i] == 0) {
            minp[i] = i;
            primes.push_back(i);
        }        
        for (auto p : primes) {
            if (i * p > n) {
                break;
            }
            minp[i * p] = p;
            if (p == minp[i]) {
                break;
            }
        }
    }
}
bool is_prime(int x){
    return (minp[x] == x);
}

void solve(){
	ll n;
	std::cin >> n;
	ll cnt = 1;
	for (auto y : primes) if (n % y == 0){
		ll tmp = 0;
		while (n % y == 0){
			tmp ++;
			n /= y;
		}
		cnt *= (tmp * 2 + 1);
	}

	std::cout << (cnt + 1) / 2 << '\n';


}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	sieve(1E6);
	int q;

	std::cin >> q;

	while (q--){
		solve();
	}

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 7724kb

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: 456ms
memory: 7600kb

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
Wrong Answer
time: 452ms
memory: 7552kb

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:

5
5
1
2
23
95
23
14
3
68
203
14
8
32
13
41
3
3
14
1
608
41
158
338
23
41
5
2
14
41
5
203
41
14
6
446
2
18
59
878
1
14
365
203
5
203
1
122
32
95
41
41
2
23
5
14
2
2
14
122
8
203
608
8
41
122
1
5
32
1
68
41
203
5
230
41
23
8
17
5
11
14
3
2
2
2
68
68
41
293
473
2
14
41
14
1
5
5
2
1
122
41
11
23
5
1
14
...

result:

wrong answer 1st lines differ - expected: '14', found: '5'