QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#730669 | #9248. An Easy Math Problem | wiseman123 | WA | 7ms | 7452kb | C++20 | 1.9kb | 2024-11-09 20:59:04 | 2024-11-09 20:59:05 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize(3)
#define int long long
#define llu unsigned long long
#define endl "\n"
#define inf 0x3f3f3f3f
#define debug cout << "****************" << endl
#define bit(x) (1LL << x)
using namespace std;
typedef pair<int, int> PII;
const int N = 5e5 + 7;
vector<int> p3(100);
void solve()
{
int q;
cin >> q;
for (int i = 1; i <= q; i++)
{
vector<int> st1;
vector<int> mp(N);
int n;
cin >> n;
for (int j = 2; j * j <= n; j++)
{
while (n % j == 0)
{
n /= j;
if (!mp[j])
st1.push_back(j);
mp[j]++;
}
}
if (n > 1)
{
if (!mp[n])
st1.push_back(n);
mp[n]++;
}
int sum = 1;
for (auto x : st1)
{
int y = mp[x];
sum *= y + 1;
}
int ans = 0;
int cnt = st1.size();
for (int j = 1; j < bit(cnt); j++) // 6e4
{
int res = 1;
int res1 = 1;
int res2 = 1;
vector<int> st2(100);
int ok = 1;
int x = j;
int now = 0;
while (x)
{
st2[now] = x % 2;
x /= 2;
now++;
}
for (int k = 0; k < st1.size(); k++)
{
if (st2[k] == 0)
res1 *= (mp[st1[k]] + 1);
else
res2 *= mp[st1[k]];
}
res = (res1 - 1) * res2;
ans += res;
}
cout << ans / 2 + sum << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
int x = 1;
cin >> T;
while (T--)
solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 7452kb
input:
10 1 2 3 4 5 6 7 8 9 10
output:
2 3 2 5 4 3 5 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
wrong answer 1st lines differ - expected: '1', found: '2'