QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#738625#9619. 乘积,欧拉函数,求和qstbcdWA 3ms5308kbC++231.9kb2024-11-12 19:34:582024-11-12 19:34:59

Judging History

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

  • [2024-11-12 19:34:59]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5308kb
  • [2024-11-12 19:34:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5;
const int mod = 998244353;
int __t = 1, n;
int prime[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 1};
void solve() {
    map<int, vector<pair<int, int>>> mp;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        int nd = 0, sum = 1;
        for (int i = 0; i < 16; i++) {
            while (x % prime[i] == 0) {
                x /= prime[i];
                if ((nd & (1 << i)) == 1)
                    sum *= prime[i];
                nd |= (1 << i);
            }
        }
        mp[x].push_back({nd, sum});
    }
    vector<int> dp(1 << 17);
    dp[0] = 1;
    for (auto [x, vec] : mp) {
        prime[16] = x;
        for (auto [nd, sum] : vec) {
            if (x != 1)
                nd |= 1 << 16;
            auto ndp = dp;
            for (int i = 0; i < (1 << 17); i++) {
                if (dp[i] == 0)
                    continue;
                int nsum = sum, nnd = nd | i;
                for (int j = 0; j < 17; j++) {
                    if ((i & (1 << j)) == 0 && (nd & (1 << j)) != 0) {
                        nsum *= max(prime[j] - 1, 1ll);
                    }
                }
                ndp[nnd] = (ndp[nnd] + dp[i] * nsum % mod) % mod;
            }
            swap(dp, ndp);
        }
        for (int i = (1 << 16); i < (1 << 17); i++) {
            int ni = i ^ (1 << 16);
            dp[ni] = (dp[ni] + dp[i]) % mod;
            dp[i] = 0;
        }
    }
    int sum = 0;
    for (auto i : dp) {
        sum = (sum + i) % mod;
    }
    cout << sum << '\n';
    return;
}
int32_t main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // cin >> __t;
    while (__t--)
        solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 5308kb

input:

5
1 6 8 6 2

output:

140

result:

wrong answer 1st lines differ - expected: '892', found: '140'