QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729708 | #9248. An Easy Math Problem | wiseman123 | WA | 1ms | 3732kb | C++20 | 1.5kb | 2024-11-09 17:39:34 | 2024-11-09 17:39:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
bool vis[N];
int prime[N];
int cnt;
void oula()
{
for (int i = 2; i < N; i++)
{
if (!vis[i])
prime[cnt++] = i;
for (int j = 0; j < cnt && i * prime[j] < N; j++)
{
vis[i * prime[j]] = 1;
if (i % prime[j] == 0)
break;
}
}
}
int po[100];
void solve()
{
int n;
cin >> n;
map<int, int> mp;
int sum = 0;
int ans = 1, tmp = 1;
for (int i = 0; i < cnt; i++)
{
int t = 0;
int prm = prime[i];
if (prm > n)
break;
while (n % prm == 0)
{
n /= prm;
t++;
}
// cout << t << "----\n";
ans *= (t + 1);
if (t)
{
mp[prm] = t;
tmp *= (t+1);
}
sum += t;
}
if (n != 1)
{
ans *= 2;
mp[n] = 1;
sum++;
}
// cout << ans << " " << tmp << endl;
int cnt = 0;
for (auto [a, k] : mp)
{
ans += k * (tmp / (k+1) - 1);
ans -= k * cnt;
cnt += k;
}
cout << ans << "\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
po[0] = 1;
for (int i = 1; i <= 60; i++)
po[i] = po[i - 1] * 2;
oula();
cin >> T;
while (T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3732kb
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: -100
Wrong Answer
time: 0ms
memory: 3732kb
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:
6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 6089 ...
result:
wrong answer 1st lines differ - expected: '29525', found: '6089'