QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#728845 | #9248. An Easy Math Problem | Whxxxxx318# | TL | 3ms | 4136kb | C++23 | 1.3kb | 2024-11-09 16:04:05 | 2024-11-09 16:04:05 |
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 qpow(int a, int b)
{
int res = 1;
while (b > 0)
{
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
void solve()
{
int n;
cin >> n;
unordered_map<int, int> mp;
int sum = 0;
int ans = 1;
for (int i = 0; i < cnt; i++)
{
int t = 0;
int prm = prime[i];
while (n % prm == 0)
{
n /= prm;
t++;
}
ans *= (t + 1);
mp[prm] = t;
sum += t;
}
for (auto [a, k] : mp)
{
ans += k * (qpow(2, sum - k) - 1);
sum -= k;
}
cout << ans << "\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
oula();
cin >> T;
while (T--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 4136kb
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
Time Limit Exceeded
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:
2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 2037 ...