QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#153737 | #7044. Easy Problem | PetroTarnavskyi# | AC ✓ | 56ms | 21276kb | C++23 | 1.7kb | 2023-08-30 20:05:42 | 2023-08-30 20:05:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FILL(a, b) memset(a, b, sizeof(a))
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int mod = 59964251;
const int phi = 59870352;
int add(int a, int b)
{
return (a + b < mod) ? (a + b) : (a + b - mod);
}
int sub(int a, int b)
{
return (a - b >= 0) ? (a - b) : (a - b + mod);
}
int mult(int a, int b)
{
return a * (LL) b % mod;
}
int binpow(int a, LL n)
{
int res = 1;
while(n)
{
if(n & 1)
res = mult(res, a);
a = mult(a, a);
n /= 2;
}
return res;
}
const int N = 2e6;
int pr[N], mu[N];
int readN()
{
string n;
cin >> n;
int res = 0;
FOR(i, 0, SZ(n))
{
res = (10 * res + (n[i] - '0')) % phi;
}
return res;
}
int a[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
mu[1] = 1;
FOR(p, 2, N)
{
if(pr[p] != 0)
continue;
for(int j = p; j < N; j += p)
{
pr[j] = 1;
if((j / p) % p == 0)
mu[j] = 0;
else
mu[j] = sub(0, mu[j / p]);
}
}
int t;
cin >> t;
while(t--)
{
int m, d, k;
int n = readN();
cin >> m >> d >> k;
m /= d;
FOR(i, 1, m + 1)
a[i] = binpow(i, k);
int ans = 0;
FOR(D, 1, m + 1)
{
int sum = 0;
for(int j = D; j <= m; j += D)
sum = add(sum, a[j]);
ans = add(ans, mult(mu[D], binpow(sum, n)));
}
ans = mult(ans, binpow(d, 1LL * k * n));
cout << ans << endl;
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 31ms
memory: 20920kb
input:
1 3 3 3 1
output:
27
result:
ok 1 number(s): "27"
Test #2:
score: 0
Accepted
time: 56ms
memory: 21276kb
input:
20 3 3 3 1 9109799336 6801 6178 261710951 7273901587 15151 659 409734533 2867553837 42265 22783 503178763 9393025453 49771 40281 632206641 8546649695 27578 8371 768172206 2453202595 27622 5445 542869700 334181849 61345 20134 20459578 2059563445 3141 1828 946541278 7244386143 69641 50850 906938712 89...
output:
27 20547372 8512644 59186649 51209646 43975644 44588858 9043868 30587070 44698073 3989303 8179341 37852631 19910063 45874282 20815913 47317834 21091711 47365734 49692924
result:
ok 20 numbers