QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#576555 | #9309. Graph | UESTC_DECAYALI | AC ✓ | 294ms | 29640kb | C++20 | 1.4kb | 2024-09-19 21:00:24 | 2024-09-19 21:00:25 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<cmath>
#define int long long
#define RI register int
#define CI const int&
using namespace std;
const int mod=998244353;
namespace Min25_Sieve
{
const int N=1e6+5;
int n,lim,pri[N],cnt,vis[N],id1[N],id2[N],g[N],w[N],idx;
inline int ID(CI x)
{
return x<=lim?id1[x]:id2[n/x];
}
inline void init(CI nn)
{
n=nn; lim=(int)sqrt(n);
for (RI i=2;i<=lim;++i)
{
if (!vis[i]) pri[++cnt]=i;
for (RI j=1;j<=cnt&&i*pri[j]<=lim;++j)
if (vis[i*pri[j]]=1,i%pri[j]==0) break;
}
for (RI l=1,r;l<=n;l=r+1)
{
r=n/(n/l); w[++idx]=n/l;
if (n/l<=lim) id1[n/l]=idx;
else id2[n/(n/l)]=idx;
g[idx]=w[idx]-1;
}
for (RI j=1;j<=cnt;++j)
for (RI i=1;i<=idx;++i)
{
if (pri[j]*pri[j]>w[i]) break;
g[i]-=g[ID(w[i]/pri[j])]-(j-1);
}
}
inline int work(CI n)
{
return n<=1?0:g[ID(n)];
}
};
using namespace Min25_Sieve;
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline int solve(CI m)
{
if (m<=2) return 1;
if (m==3) return 3;
int tot=work(m)-work(m/2);
return quick_pow(m%mod,tot)*(m%mod-(tot+1)%mod+mod)%mod;
}
signed main()
{
int n; scanf("%lld",&n);
init(n); int ans=1;
for (RI l=1,r;l<=n;l=r+1)
r=n/(n/l),(ans*=quick_pow(solve(n/l),r-l+1))%=mod;
return printf("%lld",ans),0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10084kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 1ms
memory: 9924kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 9928kb
input:
123
output:
671840470
result:
ok answer is '671840470'
Test #4:
score: 0
Accepted
time: 1ms
memory: 10024kb
input:
233
output:
353738465
result:
ok answer is '353738465'
Test #5:
score: 0
Accepted
time: 0ms
memory: 10092kb
input:
5981
output:
970246821
result:
ok answer is '970246821'
Test #6:
score: 0
Accepted
time: 0ms
memory: 10092kb
input:
86422
output:
897815688
result:
ok answer is '897815688'
Test #7:
score: 0
Accepted
time: 1ms
memory: 9936kb
input:
145444
output:
189843901
result:
ok answer is '189843901'
Test #8:
score: 0
Accepted
time: 2ms
memory: 10028kb
input:
901000
output:
819449452
result:
ok answer is '819449452'
Test #9:
score: 0
Accepted
time: 2ms
memory: 9912kb
input:
1000000
output:
113573943
result:
ok answer is '113573943'
Test #10:
score: 0
Accepted
time: 0ms
memory: 10184kb
input:
23333333
output:
949849384
result:
ok answer is '949849384'
Test #11:
score: 0
Accepted
time: 5ms
memory: 10188kb
input:
102850434
output:
604886751
result:
ok answer is '604886751'
Test #12:
score: 0
Accepted
time: 15ms
memory: 12816kb
input:
998244353
output:
0
result:
ok answer is '0'
Test #13:
score: 0
Accepted
time: 11ms
memory: 12964kb
input:
1000000007
output:
318420284
result:
ok answer is '318420284'
Test #14:
score: 0
Accepted
time: 20ms
memory: 14784kb
input:
2147483547
output:
688759898
result:
ok answer is '688759898'
Test #15:
score: 0
Accepted
time: 42ms
memory: 15956kb
input:
5120103302
output:
116870489
result:
ok answer is '116870489'
Test #16:
score: 0
Accepted
time: 95ms
memory: 17608kb
input:
19834593299
output:
523663743
result:
ok answer is '523663743'
Test #17:
score: 0
Accepted
time: 185ms
memory: 22240kb
input:
52500109238
output:
195086665
result:
ok answer is '195086665'
Test #18:
score: 0
Accepted
time: 258ms
memory: 27180kb
input:
84848352911
output:
107959260
result:
ok answer is '107959260'
Test #19:
score: 0
Accepted
time: 293ms
memory: 28312kb
input:
99824435322
output:
0
result:
ok answer is '0'
Test #20:
score: 0
Accepted
time: 286ms
memory: 29640kb
input:
99999999354
output:
316301711
result:
ok answer is '316301711'
Test #21:
score: 0
Accepted
time: 294ms
memory: 28956kb
input:
100000000000
output:
396843576
result:
ok answer is '396843576'
Extra Test:
score: 0
Extra Test Passed