QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#568998 | #9309. Graph | ucup-team4504 | AC ✓ | 307ms | 17956kb | C++14 | 2.1kb | 2024-09-16 19:48:22 | 2024-09-16 19:48:22 |
Judging History
answer
//#pragma GCC optimize("Ofast","inline","-ffast-math")
//#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define MOD 998244353
using namespace __gnu_pbds;
using namespace std;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
long long n,a[700010],f[700010];
int base,cnt,vis[350010],pri[350010],dp[700010];
inline void add1(int &x,int y)
{
x+=y;
if(x>=MOD) x-=MOD;
}
inline void add2(int &x,int y)
{
x+=y;
if(x<0) x+=MOD;
}
inline int my_pow(int x,long long y)
{
if(y==0) return 1;
if(y==1) return x;
int res=my_pow(x,y/2);
if(y%2==0) return 1ll*res*res%MOD;
else return 1ll*res*res%MOD*x%MOD;
}
inline int id(long long x)
{
if(x<=base) return x;
return 2*base+1-n/x;
}
inline void init()
{
for(int i=2;i<=base;i++){
if(!vis[i]) pri[++cnt]=i;
for(int j=1;j<=cnt&&i*pri[j]<=base;j++){
vis[i*pri[j]]=1;
if(i%pri[j]==0) break;
}
}
for(int i=1;i<=base;i++) a[i]=i;
for(int i=1;i<=base;i++) a[2*base+1-i]=n/i;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>n;base=(int)sqrtl(n);init();
for(int i=1;i<=2*base;i++) f[i]=a[i]-1;
int pos=1;
for(int i=1;i<=cnt;i++){
while(1ll*pri[i]*pri[i]>a[pos]) pos++;
for(int j=2*base;j>=pos;j--){
f[j]-=f[id(a[j]/pri[i])]-(i-1);
}
}
int ans=1;
for(long long i=1,j;i<=n;i=j+1){
j=n/(n/i);
long long len=j-i+1,tot=n/i;
if(tot<=2) continue;
long long num=f[id(n/i)]-f[id(n/i/2)]+1;
if(tot==3) num--;
int cur=1ll*my_pow(tot%MOD,num-1)*((tot-num)%MOD)%MOD;
ans=1ll*ans*my_pow(cur,len)%MOD;
}
cout<<ans<<'\n';
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9700kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 7732kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7696kb
input:
123
output:
671840470
result:
ok answer is '671840470'
Test #4:
score: 0
Accepted
time: 1ms
memory: 9724kb
input:
233
output:
353738465
result:
ok answer is '353738465'
Test #5:
score: 0
Accepted
time: 1ms
memory: 9740kb
input:
5981
output:
970246821
result:
ok answer is '970246821'
Test #6:
score: 0
Accepted
time: 1ms
memory: 9784kb
input:
86422
output:
897815688
result:
ok answer is '897815688'
Test #7:
score: 0
Accepted
time: 1ms
memory: 9844kb
input:
145444
output:
189843901
result:
ok answer is '189843901'
Test #8:
score: 0
Accepted
time: 1ms
memory: 9700kb
input:
901000
output:
819449452
result:
ok answer is '819449452'
Test #9:
score: 0
Accepted
time: 0ms
memory: 7740kb
input:
1000000
output:
113573943
result:
ok answer is '113573943'
Test #10:
score: 0
Accepted
time: 0ms
memory: 7856kb
input:
23333333
output:
949849384
result:
ok answer is '949849384'
Test #11:
score: 0
Accepted
time: 5ms
memory: 9828kb
input:
102850434
output:
604886751
result:
ok answer is '604886751'
Test #12:
score: 0
Accepted
time: 16ms
memory: 11976kb
input:
998244353
output:
0
result:
ok answer is '0'
Test #13:
score: 0
Accepted
time: 16ms
memory: 11744kb
input:
1000000007
output:
318420284
result:
ok answer is '318420284'
Test #14:
score: 0
Accepted
time: 26ms
memory: 11688kb
input:
2147483547
output:
688759898
result:
ok answer is '688759898'
Test #15:
score: 0
Accepted
time: 44ms
memory: 7980kb
input:
5120103302
output:
116870489
result:
ok answer is '116870489'
Test #16:
score: 0
Accepted
time: 106ms
memory: 15976kb
input:
19834593299
output:
523663743
result:
ok answer is '523663743'
Test #17:
score: 0
Accepted
time: 196ms
memory: 17956kb
input:
52500109238
output:
195086665
result:
ok answer is '195086665'
Test #18:
score: 0
Accepted
time: 271ms
memory: 15116kb
input:
84848352911
output:
107959260
result:
ok answer is '107959260'
Test #19:
score: 0
Accepted
time: 298ms
memory: 17332kb
input:
99824435322
output:
0
result:
ok answer is '0'
Test #20:
score: 0
Accepted
time: 307ms
memory: 15508kb
input:
99999999354
output:
316301711
result:
ok answer is '316301711'
Test #21:
score: 0
Accepted
time: 302ms
memory: 15524kb
input:
100000000000
output:
396843576
result:
ok answer is '396843576'
Extra Test:
score: 0
Extra Test Passed