QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#578894 | #9309. Graph | SSL_TJH | WA | 1ms | 8216kb | C++14 | 1.6kb | 2024-09-20 22:29:43 | 2024-09-20 22:29:43 |
Judging History
answer
#include<bits/stdc++.h>
#define MOD 998244353
using namespace std;
typedef long long ll;
const ll MAXN=1e11;
const int N=1e5;
// SQRN is exactly floor(sqrt(n)), PNUM is the number of primes not greater than SQRN
ll POW(ll x, ll y) {
ll re = 1;
while (y) {
if (y & 1) re = re * x % MOD;
x = x * x % MOD; y >>= 1;
}
return re;
}
int p1,vt,z[N+5],pr[N+5];
long long n,x,v[N+5],f[2][N+5],s[N+5],g[N+5];
void dd(){
for(int i=2;i<=N;i++){
if(!z[i]){
pr[++p1]=i;
s[p1]=p1;
}
for(int j=1;j<=p1&&i*pr[j]<=N;j++){
z[i*pr[j]]=1;
if(i%pr[j]==0) break;
}
}
}
void init(){
x=sqrt(n)+1;
vt = 0;
for(long long l=1,r;l<=n;l=r+1){
r=n/(n/l);
v[++vt]=n/l;
if(n/l<=x) f[0][n/l]=vt;
else f[1][l]=vt;
long long t=n/l;
g[vt]=t-1;
}
long long w;
for(int i=1;i<=p1;i++){
w=1ll*pr[i]*pr[i];
long long t;
for(int j=1;j<=vt&&w<=v[j];j++){
t=v[j]/pr[i];
if(t<=x) t=f[0][t];
else t=f[1][n/t];
g[j]-=g[t]-s[i-1];
}
}
}
long long S(long long p,int q){
if(pr[q]>=p) return 0;
long long td=(p<=x?f[0][p]:f[1][n/p]);
long long re=g[td]-s[q];
return re;
}
int quest(ll m) {
n = m;
init();
return S(n,0);
}
int main() {
dd();
ll nn;
scanf("%lld", &nn);
if (nn == 2) {
printf("1"); return 0;
}
if (nn == 3) {
printf("3"); return 0;
}
ll re = 1;
for (ll L = 1, R; L <= nn; L = R + 1) {
R = nn / (nn / L);
int k = (nn / L) % MOD;
ll awa = quest(k) - quest(k / 2);
if (!awa) continue;
(re *= awa % MOD * POW(k, awa) % MOD) %= MOD;
}
printf("%lld", re);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6412kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8216kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 6324kb
input:
123
output:
78784667
result:
wrong answer expected '671840470', found '78784667'