QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#574850 | #9309. Graph | gxy001 | AC ✓ | 144ms | 8100kb | C++23 | 1.1kb | 2024-09-19 01:52:07 | 2024-09-19 01:52:08 |
Judging History
answer
#include<iostream>
#include<cmath>
using std::cin,std::cout;
int const mod=998244353;
int pow(int x,int y){
int res=1;
while(y){
if(y&1) res=1ll*res*x%mod;
x=1ll*x*x%mod,y>>=1;
}
return res;
}
int f0[400010],t,m;
long long n,f1[400010];
auto divide=[](long long N,long long d)->int{return double(N)/d;};
inline long long get(long long x){
return x<=m?f0[x]:f1[divide(n,x)];
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin>>n;
m=std::sqrt(n);
for(int i=1;i<=m;i++){
f0[i]=i;
f1[i]=(n/i);
}
for(int i=2;i<=m;i++)if(f0[i]!=f0[i-1]){
int x=f0[i-1];
long long r=1ll*i*i;
int u=std::min(1ll*m,n/r),uu=std::min(u,divide(m,i));
for(int j=1;j<=uu;j++) f1[j]=f1[j]-f1[i*j]+x;
long long t=n/i;
for(int j=uu+1;j<=u;j++) f1[j]=f1[j]-f0[divide(t,j)]+x;
for(int j=m;j>=r;j--) f0[j]=f0[j]-f0[divide(j,i)]+x;
}
int ans=1;
for(long long l=1,r;l<=n;l=r+1){
r=n/(n/l);
long long u=n/l;
if(u<=2) break;
long long k=get(u)-get(u/2);
int f=1ll*pow(int(u%mod),int(k%(mod-1)))*((u-k-1)%mod)%mod;
if(u==3) f=3;
ans=1ll*ans*pow(f,int((r-l+1)%(mod-1)))%mod;
}
cout<<ans<<'\n';
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5620kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5712kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
123
output:
671840470
result:
ok answer is '671840470'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5824kb
input:
233
output:
353738465
result:
ok answer is '353738465'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5756kb
input:
5981
output:
970246821
result:
ok answer is '970246821'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5668kb
input:
86422
output:
897815688
result:
ok answer is '897815688'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5756kb
input:
145444
output:
189843901
result:
ok answer is '189843901'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
901000
output:
819449452
result:
ok answer is '819449452'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5704kb
input:
1000000
output:
113573943
result:
ok answer is '113573943'
Test #10:
score: 0
Accepted
time: 0ms
memory: 5680kb
input:
23333333
output:
949849384
result:
ok answer is '949849384'
Test #11:
score: 0
Accepted
time: 0ms
memory: 5908kb
input:
102850434
output:
604886751
result:
ok answer is '604886751'
Test #12:
score: 0
Accepted
time: 8ms
memory: 5928kb
input:
998244353
output:
0
result:
ok answer is '0'
Test #13:
score: 0
Accepted
time: 8ms
memory: 4024kb
input:
1000000007
output:
318420284
result:
ok answer is '318420284'
Test #14:
score: 0
Accepted
time: 10ms
memory: 6116kb
input:
2147483547
output:
688759898
result:
ok answer is '688759898'
Test #15:
score: 0
Accepted
time: 22ms
memory: 4484kb
input:
5120103302
output:
116870489
result:
ok answer is '116870489'
Test #16:
score: 0
Accepted
time: 51ms
memory: 6736kb
input:
19834593299
output:
523663743
result:
ok answer is '523663743'
Test #17:
score: 0
Accepted
time: 95ms
memory: 7648kb
input:
52500109238
output:
195086665
result:
ok answer is '195086665'
Test #18:
score: 0
Accepted
time: 129ms
memory: 7940kb
input:
84848352911
output:
107959260
result:
ok answer is '107959260'
Test #19:
score: 0
Accepted
time: 144ms
memory: 8032kb
input:
99824435322
output:
0
result:
ok answer is '0'
Test #20:
score: 0
Accepted
time: 144ms
memory: 8100kb
input:
99999999354
output:
316301711
result:
ok answer is '316301711'
Test #21:
score: 0
Accepted
time: 144ms
memory: 7936kb
input:
100000000000
output:
396843576
result:
ok answer is '396843576'
Extra Test:
score: 0
Extra Test Passed