QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#809045 | #9248. An Easy Math Problem | Hiraethsoul# | WA | 479ms | 4552kb | C++23 | 1.9kb | 2024-12-11 10:59:15 | 2024-12-11 10:59:16 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
struct Prime
{
int n;
int cnt = 0;
std::vector<int> a, vis;
Prime(int n) : n(n), a(n + 1), vis(n + 1)
{
auto get_prime = [&]()
{
vis[0] = vis[1] = true;
for (int i = 2; i <= n; ++i)
{
if (!vis[i])
{
a[++cnt] = i;
}
for (int j = 1; j <= cnt and i * a[j] <= n; ++j)
{
vis[i * a[j]] = 1;
if (i % a[j] == 0)
{
break;
}
}
}
};
get_prime();
a.resize(cnt + 1);
}
};
Prime P(1e5);
signed main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int t;
std::cin >> t;
while (t--)
{
int x;
std::cin >> x;
std::vector<int> fac;
for (int i = 1; i * i <= x; ++i)
{
if (x % i == 0)
{
fac.push_back(i);
if (i * i != x)
{
fac.push_back(x / i);
}
}
}
auto check = [&](int x)
{
for (int i = 2; i * i <= x; ++i)
{
if (x % i == 0)
{
return false;
}
}
return true;
};
int cnt = 0;
for (auto i : fac)
{
if (i <= 1e5 and !P.vis[i])
{
++cnt;
}
else if (i > 1e5)
{
cnt += check(i);
}
}
int ans = fac.size() + cnt * (cnt - 1) / 2;
std::cout << ans << '\n';
}
// 最多只有一个>=sqrt(n)的质因子
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 4552kb
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: 479ms
memory: 4424kb
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:
1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 1069 ...
result:
wrong answer 1st lines differ - expected: '29525', found: '1069'