QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#743622 | #9619. 乘积,欧拉函数,求和 | wht11 | WA | 447ms | 4280kb | C++14 | 1.8kb | 2024-11-13 19:39:58 | 2024-11-13 19:40:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int N = 2e5 + 10;
int t = 1, n;
int p[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int dp[1 << 16];
int qpow(int a, int n)
{
int res = 1;
while (n)
{
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res % mod;
}
void solve()
{
map<int, vector<pair<int, int>>> mp;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
int tmp = a[i];
int msk = 0;
for (int i = 0; i < 16; i++)
{
if (tmp % p[i] == 0)
{
while (tmp % p[i] == 0)
tmp /= p[i];
msk |= 1 << i;
}
}
mp[tmp].push_back({msk, a[i]});
}
dp[0] = 1;
for (auto node : mp)
{
int x = node.first;
auto ve = node.second;
int lst = max(x - 1, 1ll) % mod * qpow(x, mod - 2);
for (auto tmp : ve)
{
int msk = tmp.first;
int val = tmp.second;
for (int i = (1 << 16) - 1; i >= 0; i--)
dp[i | msk] = (dp[i | msk] + dp[i] * val % mod * lst % mod) % mod;
}
}
int ans = 0;
for (int i = 0; i < (1 << 16); i++)
{
for (int j = 0; j < 16; j++)
{
if (i & (1 << j))
dp[i] = dp[i] * max(p[j] - 1, 1ll) * qpow(p[j], mod - 2) % mod % mod;
}
ans = (ans + dp[i]) % mod;
}
cout << ans << endl;
return;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 62ms
memory: 4260kb
input:
5 1 6 8 6 2
output:
892
result:
ok single line: '892'
Test #2:
score: 0
Accepted
time: 62ms
memory: 4264kb
input:
5 3 8 3 7 8
output:
3157
result:
ok single line: '3157'
Test #3:
score: -100
Wrong Answer
time: 447ms
memory: 4280kb
input:
2000 79 1 1 1 1 1 1 2803 1 1 1 1 1 1 1609 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2137 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 613 1 499 1 211 1 2927 1 1 1327 1 1 1123 1 907 1 2543 1 1 1 311 2683 1 1 1 1 2963 1 1 1 641 761 1 1 1 1 1 1 1 1 1 1 1 1489 2857 1 1 1 1 1 1 1 1 1 1 1 1 1 967 1 821 1 1 1 1 2143 1861...
output:
172381490
result:
wrong answer 1st lines differ - expected: '50965652', found: '172381490'