QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177872 | #7225. The Kirakira Cycle | Crysfly# | AC ✓ | 2898ms | 204760kb | C++17 | 2.8kb | 2023-09-13 14:55:43 | 2023-09-13 14:55:43 |
Judging History
answer
// what is matter? never mind.
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 998244353
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,int b){return a.x==b;}
friend bool operator !=(modint a,int b){return a.x!=b;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 10005
#define inf 0x3f3f3f3f
int n,m;
int f[50000005];
bitset<50000005>vis;
signed main()
{
n=read();
if(n==1){
puts("1");
exit(0);
}
m=n*(n-1)/2;
For(i,1,n){
for(int j=i;j<=m;j+=i)
f[j]-=i;
}
For(i,1,m) f[i]+=f[i-1],f[i]+=n;
// For(i,1,m) cout<<f[i]<<" "; cout<<"\n";
int res=0;
int tim=0;
For(i,1,m)
if(!vis[i]){
int u=i;
int nowt=tim;
while(!vis[u]){
int v=f[u];
f[u]=++tim;
vis[u]=1;
u=v;
}
if(f[u]>nowt){
res=max(res,tim-f[u]+1);
}
}
cout<<res;
return 0;
}
/*
*/
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5460kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
10
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
43
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5556kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
4
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
5
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
6
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
7
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3380kb
input:
8
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3368kb
input:
11
output:
7
result:
ok 1 number(s): "7"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
13
output:
6
result:
ok 1 number(s): "6"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
17
output:
4
result:
ok 1 number(s): "4"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
19
output:
5
result:
ok 1 number(s): "5"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3380kb
input:
23
output:
3
result:
ok 1 number(s): "3"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
29
output:
2
result:
ok 1 number(s): "2"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
31
output:
13
result:
ok 1 number(s): "13"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
37
output:
5
result:
ok 1 number(s): "5"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3368kb
input:
41
output:
21
result:
ok 1 number(s): "21"
Test #21:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
60
output:
8
result:
ok 1 number(s): "8"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
100
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
105
output:
41
result:
ok 1 number(s): "41"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3404kb
input:
128
output:
31
result:
ok 1 number(s): "31"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
130
output:
25
result:
ok 1 number(s): "25"
Test #26:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
256
output:
52
result:
ok 1 number(s): "52"
Test #27:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
290
output:
15
result:
ok 1 number(s): "15"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
455
output:
104
result:
ok 1 number(s): "104"
Test #29:
score: 0
Accepted
time: 2ms
memory: 3944kb
input:
512
output:
45
result:
ok 1 number(s): "45"
Test #30:
score: 0
Accepted
time: 4ms
memory: 4588kb
input:
777
output:
35
result:
ok 1 number(s): "35"
Test #31:
score: 0
Accepted
time: 3ms
memory: 4452kb
input:
707
output:
175
result:
ok 1 number(s): "175"
Test #32:
score: 0
Accepted
time: 1ms
memory: 3940kb
input:
449
output:
13
result:
ok 1 number(s): "13"
Test #33:
score: 0
Accepted
time: 2ms
memory: 4096kb
input:
573
output:
168
result:
ok 1 number(s): "168"
Test #34:
score: 0
Accepted
time: 5ms
memory: 4936kb
input:
858
output:
49
result:
ok 1 number(s): "49"
Test #35:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
230
output:
58
result:
ok 1 number(s): "58"
Test #36:
score: 0
Accepted
time: 3ms
memory: 5272kb
input:
972
output:
117
result:
ok 1 number(s): "117"
Test #37:
score: 0
Accepted
time: 4ms
memory: 4808kb
input:
844
output:
47
result:
ok 1 number(s): "47"
Test #38:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
378
output:
37
result:
ok 1 number(s): "37"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
423
output:
49
result:
ok 1 number(s): "49"
Test #40:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
209
output:
20
result:
ok 1 number(s): "20"
Test #41:
score: 0
Accepted
time: 658ms
memory: 67600kb
input:
5645
output:
338
result:
ok 1 number(s): "338"
Test #42:
score: 0
Accepted
time: 41ms
memory: 11744kb
input:
2034
output:
249
result:
ok 1 number(s): "249"
Test #43:
score: 0
Accepted
time: 844ms
memory: 79868kb
input:
6163
output:
206
result:
ok 1 number(s): "206"
Test #44:
score: 0
Accepted
time: 920ms
memory: 86492kb
input:
6422
output:
346
result:
ok 1 number(s): "346"
Test #45:
score: 0
Accepted
time: 17ms
memory: 8264kb
input:
1550
output:
40
result:
ok 1 number(s): "40"
Test #46:
score: 0
Accepted
time: 1133ms
memory: 100300kb
input:
6940
output:
674
result:
ok 1 number(s): "674"
Test #47:
score: 0
Accepted
time: 37ms
memory: 12032kb
input:
2068
output:
157
result:
ok 1 number(s): "157"
Test #48:
score: 0
Accepted
time: 840ms
memory: 80756kb
input:
6197
output:
594
result:
ok 1 number(s): "594"
Test #49:
score: 0
Accepted
time: 928ms
memory: 87364kb
input:
6456
output:
913
result:
ok 1 number(s): "913"
Test #50:
score: 0
Accepted
time: 2044ms
memory: 158492kb
input:
8776
output:
423
result:
ok 1 number(s): "423"
Test #51:
score: 0
Accepted
time: 237ms
memory: 34120kb
input:
3904
output:
281
result:
ok 1 number(s): "281"
Test #52:
score: 0
Accepted
time: 274ms
memory: 38416kb
input:
4163
output:
230
result:
ok 1 number(s): "230"
Test #53:
score: 0
Accepted
time: 328ms
memory: 42788kb
input:
4422
output:
631
result:
ok 1 number(s): "631"
Test #54:
score: 0
Accepted
time: 393ms
memory: 47488kb
input:
4681
output:
95
result:
ok 1 number(s): "95"
Test #55:
score: 0
Accepted
time: 2046ms
memory: 159696kb
input:
8810
output:
835
result:
ok 1 number(s): "835"
Test #56:
score: 0
Accepted
time: 240ms
memory: 34656kb
input:
3938
output:
350
result:
ok 1 number(s): "350"
Test #57:
score: 0
Accepted
time: 2390ms
memory: 178616kb
input:
9328
output:
373
result:
ok 1 number(s): "373"
Test #58:
score: 0
Accepted
time: 348ms
memory: 43436kb
input:
4456
output:
932
result:
ok 1 number(s): "932"
Test #59:
score: 0
Accepted
time: 419ms
memory: 48216kb
input:
4715
output:
476
result:
ok 1 number(s): "476"
Test #60:
score: 0
Accepted
time: 1449ms
memory: 120700kb
input:
7633
output:
591
result:
ok 1 number(s): "591"
Test #61:
score: 0
Accepted
time: 96ms
memory: 18668kb
input:
2762
output:
263
result:
ok 1 number(s): "263"
Test #62:
score: 0
Accepted
time: 1691ms
memory: 137260kb
input:
8152
output:
465
result:
ok 1 number(s): "465"
Test #63:
score: 0
Accepted
time: 143ms
memory: 25080kb
input:
3280
output:
157
result:
ok 1 number(s): "157"
Test #64:
score: 0
Accepted
time: 179ms
memory: 28600kb
input:
3539
output:
79
result:
ok 1 number(s): "79"
Test #65:
score: 0
Accepted
time: 1494ms
memory: 121984kb
input:
7668
output:
905
result:
ok 1 number(s): "905"
Test #66:
score: 0
Accepted
time: 1620ms
memory: 129964kb
input:
7927
output:
357
result:
ok 1 number(s): "357"
Test #67:
score: 0
Accepted
time: 1732ms
memory: 138372kb
input:
8186
output:
543
result:
ok 1 number(s): "543"
Test #68:
score: 0
Accepted
time: 161ms
memory: 25480kb
input:
3314
output:
306
result:
ok 1 number(s): "306"
Test #69:
score: 0
Accepted
time: 181ms
memory: 29124kb
input:
3573
output:
69
result:
ok 1 number(s): "69"
Test #70:
score: 0
Accepted
time: 1171ms
memory: 98684kb
input:
6873
output:
667
result:
ok 1 number(s): "667"
Test #71:
score: 0
Accepted
time: 31ms
memory: 11432kb
input:
2001
output:
134
result:
ok 1 number(s): "134"
Test #72:
score: 0
Accepted
time: 1370ms
memory: 113428kb
input:
7391
output:
477
result:
ok 1 number(s): "477"
Test #73:
score: 0
Accepted
time: 71ms
memory: 16364kb
input:
2519
output:
267
result:
ok 1 number(s): "267"
Test #74:
score: 0
Accepted
time: 102ms
memory: 19048kb
input:
2778
output:
162
result:
ok 1 number(s): "162"
Test #75:
score: 0
Accepted
time: 129ms
memory: 21936kb
input:
3037
output:
282
result:
ok 1 number(s): "282"
Test #76:
score: 0
Accepted
time: 158ms
memory: 25184kb
input:
3296
output:
458
result:
ok 1 number(s): "458"
Test #77:
score: 0
Accepted
time: 1406ms
memory: 114640kb
input:
7426
output:
214
result:
ok 1 number(s): "214"
Test #78:
score: 0
Accepted
time: 78ms
memory: 16512kb
input:
2554
output:
102
result:
ok 1 number(s): "102"
Test #79:
score: 0
Accepted
time: 1663ms
memory: 130512kb
input:
7944
output:
283
result:
ok 1 number(s): "283"
Test #80:
score: 0
Accepted
time: 889ms
memory: 78628kb
input:
6113
output:
121
result:
ok 1 number(s): "121"
Test #81:
score: 0
Accepted
time: 2898ms
memory: 204760kb
input:
10000
output:
917
result:
ok 1 number(s): "917"
Test #82:
score: 0
Accepted
time: 2780ms
memory: 204724kb
input:
9999
output:
470
result:
ok 1 number(s): "470"
Test #83:
score: 0
Accepted
time: 2848ms
memory: 204680kb
input:
9998
output:
1552
result:
ok 1 number(s): "1552"
Test #84:
score: 0
Accepted
time: 2856ms
memory: 204692kb
input:
9997
output:
538
result:
ok 1 number(s): "538"
Test #85:
score: 0
Accepted
time: 2772ms
memory: 204684kb
input:
9996
output:
193
result:
ok 1 number(s): "193"
Test #86:
score: 0
Accepted
time: 2817ms
memory: 204616kb
input:
9995
output:
624
result:
ok 1 number(s): "624"
Test #87:
score: 0
Accepted
time: 2735ms
memory: 204708kb
input:
9994
output:
481
result:
ok 1 number(s): "481"
Test #88:
score: 0
Accepted
time: 2814ms
memory: 204484kb
input:
9993
output:
617
result:
ok 1 number(s): "617"
Test #89:
score: 0
Accepted
time: 2749ms
memory: 204380kb
input:
9992
output:
433
result:
ok 1 number(s): "433"
Test #90:
score: 0
Accepted
time: 2778ms
memory: 204448kb
input:
9991
output:
425
result:
ok 1 number(s): "425"
Test #91:
score: 0
Accepted
time: 2792ms
memory: 204424kb
input:
9990
output:
509
result:
ok 1 number(s): "509"
Test #92:
score: 0
Accepted
time: 2762ms
memory: 204548kb
input:
9989
output:
808
result:
ok 1 number(s): "808"
Test #93:
score: 0
Accepted
time: 2806ms
memory: 204204kb
input:
9988
output:
734
result:
ok 1 number(s): "734"
Test #94:
score: 0
Accepted
time: 2767ms
memory: 204252kb
input:
9987
output:
922
result:
ok 1 number(s): "922"
Test #95:
score: 0
Accepted
time: 2805ms
memory: 204284kb
input:
9986
output:
1252
result:
ok 1 number(s): "1252"
Test #96:
score: 0
Accepted
time: 2807ms
memory: 204224kb
input:
9985
output:
378
result:
ok 1 number(s): "378"
Test #97:
score: 0
Accepted
time: 2811ms
memory: 204260kb
input:
9984
output:
472
result:
ok 1 number(s): "472"
Test #98:
score: 0
Accepted
time: 2813ms
memory: 204280kb
input:
9983
output:
363
result:
ok 1 number(s): "363"
Test #99:
score: 0
Accepted
time: 2830ms
memory: 204208kb
input:
9982
output:
1121
result:
ok 1 number(s): "1121"
Test #100:
score: 0
Accepted
time: 2827ms
memory: 204052kb
input:
9981
output:
261
result:
ok 1 number(s): "261"
Test #101:
score: 0
Accepted
time: 2870ms
memory: 204100kb
input:
9980
output:
228
result:
ok 1 number(s): "228"
Test #102:
score: 0
Accepted
time: 24ms
memory: 9968kb
input:
1811
output:
2
result:
ok 1 number(s): "2"
Test #103:
score: 0
Accepted
time: 665ms
memory: 66524kb
input:
5598
output:
14
result:
ok 1 number(s): "14"
Test #104:
score: 0
Accepted
time: 67ms
memory: 15552kb
input:
2466
output:
33
result:
ok 1 number(s): "33"
Extra Test:
score: 0
Extra Test Passed