QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#689499 | #9248. An Easy Math Problem | huanxiel# | WA | 2ms | 8988kb | C++20 | 2.2kb | 2024-10-30 17:25:40 | 2024-10-30 17:25:41 |
Judging History
This is the latest submission verdict.
- [2024-10-31 22:36:43]
- hack成功,自动添加数据
- (/hack/1098)
- [2024-10-31 22:13:58]
- hack成功,自动添加数据
- (/hack/1096)
- [2024-10-31 22:00:43]
- hack成功,自动添加数据
- (/hack/1095)
- [2024-10-30 17:25:40]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
typedef double db;
const db eps = 1e-8;
#define inf 1e18
#define ret \
{ \
cout << -1 << endl; \
return; \
}
template <typename T>
bool gmax(T &x, const T y)
{
if (x < y)
return x = y, 1;
return 0;
}
template <typename T>
bool gmin(T &x, const T y)
{
if (y < x)
return x = y, 1;
return 0;
}
#define maxn 200003
ll isn_prime[maxn], primes[1000000], pnum = 0;
void init()
{
isn_prime[0] = isn_prime[1] = 1;
rep(i, 2, maxn - 3)
{
if (!isn_prime[i])
primes[++pnum] = i;
for (int j = 1; j <= pnum && primes[j] * i <= maxn - 3; ++j)
{
isn_prime[primes[j] * i] = 1;
if (i % primes[j] == 0)
break;
}
}
}
void solve()
{
ll x, cnt1 = 0, cnt2 = 0, j = 1;
cin >> x;
if (x == 1)
{
cout << 1 << endl;
return;
}
while (x != 1 && j < 1e5 + 1 && primes[j] <= x)
{
int k = 0;
while (x % primes[j] == 0)
{
k++;
cnt1++;
x /= primes[j];
}
if (k)
cnt2++;
j++;
}
if (x != 1 || cnt2 == 1)
{
cout << cnt1 + 1 << endl;
return;
}
cout << (1ll * cnt2 * cnt2 - cnt2) / 2 + 2 + cnt1 << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
init();
cin >> t;
while (t--)
solve();
}
// 循环边界
// 二分l和r的范围
// 数组越界
// 在函数内开数组赋初值
// long long
// 尽量用数学语言刻画
// 从直觉到严谨分析,推导
// 冷静,冷静,冷静
// if(mp[x]) 会生成新的键值
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 6020kb
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: 8988kb
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:
57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 ...
result:
wrong answer 1st lines differ - expected: '29525', found: '57'