QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746721#9619. 乘积,欧拉函数,求和LeNcyerWA 0ms3672kbC++201.4kb2024-11-14 15:21:532024-11-14 15:21:53

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 15:21:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-11-14 15:21:53]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'