QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#746721 | #9619. 乘积,欧拉函数,求和 | LeNcyer | WA | 0ms | 3672kb | C++20 | 1.4kb | 2024-11-14 15:21:53 | 2024-11-14 15:21:53 |
Judging History
answer
#include<bits/stdc++.h>
#ifndef LOCAL
#define endl '\n'
#endif
#define ast cout << "debug" << endl
#define debug(n) cout << #n << " = " << n << endl
#define debugv( v ) for( auto e : v ) cout << e << endl
#define debugm( m ) for( auto [f, s] : m ) cout << f << " : " << s << endl;
using namespace std;
using ll = long long;
const int maxn = 3005;
const ll mod = 998244353;
ll phi[maxn], prime[maxn], cnt;
bool is_prime[maxn];
void getphi() {
for (int i = 1; i <= maxn; i++) {
is_prime[i] = 1;
}
int cnt = 0;
is_prime[1] = 0;
phi[1] = 1;
for (int i = 2; i <= maxn; i++) {
if (is_prime[i]) {
prime[++cnt] = i;
phi[i] = i - 1;
}
for (int j = 1; j <= cnt && i * prime[j] <= maxn; j++) {
is_prime[i * prime[j]] = 0;
if (i % prime[j])
phi[i * prime[j]] = phi[i] * phi[prime[j]];
else {
phi[i * prime[j]] = phi[i] * prime[j];
break;
}
}
}
}
void solve()
{
int n;
cin >> n;
ll ans = 1;
for(int i = 1; i <= n; i++) {
int x;
cin >> x;
ans = (ans + ans * phi[x] % mod) % mod;
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll t = 1;
// cin >> t;
getphi();
while(t--)
solve();
#ifdef LOCAL
system("pause");
#endif
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3672kb
input:
5 1 6 8 6 2
output:
180
result:
wrong answer 1st lines differ - expected: '892', found: '180'