QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#468786 | #7225. The Kirakira Cycle | inksamurai | AC ✓ | 2012ms | 245040kb | C++23 | 1.3kb | 2024-07-09 00:48:19 | 2024-07-09 00:48:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int) a.size()
#define all(a) a.begin(),a.end()
#define vec(...) vector<__VA_ARGS__>
#define _3zlqvu8 ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
const int L=30399200;
bitset<L> usd;
int qs[L+11];
int f[L+11];
const int L1=L;
void slv(int n){
for(int i=1;i<=n;i++){
for(int x=i;x<=L;x+=i){
f[x]-=x;
if(x+i<=L) f[x+i]+=x;
}
}
ll val=0;
for(int i=1;i<=L;i++){
val+=f[i];
f[i]=val+(1ll)*i*n;
}
int ans=0;
rng(a,1,L1+1){
if(qs[a]) continue;
vi delay;
int x=a,step=1;
while(1){
if(x>L) break;
if(qs[x]){
if(usd[x]) ans=max(ans,step-qs[x]);
break;
}
delay.pb(x);
usd[x]=1;
qs[x]=step;
x=f[x];
step+=1;
}
for(auto x:delay) usd[x]=0;
}
cout<<ans<<"\n";
}
signed main(){
_3zlqvu8;
// for(int n=1;n<=20;n++)
// {
// slv(100);
// rep(i,L) usd[i]=qs[i]=f[i]=0;
// }
int n;
cin>>n;
slv(n);
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 572ms
memory: 245028kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 629ms
memory: 244732kb
input:
10
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 861ms
memory: 244744kb
input:
43
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: 0
Accepted
time: 515ms
memory: 244680kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 553ms
memory: 244744kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 527ms
memory: 244792kb
input:
4
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 561ms
memory: 244748kb
input:
5
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: 0
Accepted
time: 557ms
memory: 245012kb
input:
6
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 581ms
memory: 244764kb
input:
7
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 571ms
memory: 244816kb
input:
8
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 595ms
memory: 245012kb
input:
9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 625ms
memory: 244812kb
input:
11
output:
7
result:
ok 1 number(s): "7"
Test #13:
score: 0
Accepted
time: 615ms
memory: 244728kb
input:
13
output:
6
result:
ok 1 number(s): "6"
Test #14:
score: 0
Accepted
time: 668ms
memory: 244796kb
input:
17
output:
4
result:
ok 1 number(s): "4"
Test #15:
score: 0
Accepted
time: 699ms
memory: 244732kb
input:
19
output:
5
result:
ok 1 number(s): "5"
Test #16:
score: 0
Accepted
time: 714ms
memory: 244680kb
input:
23
output:
3
result:
ok 1 number(s): "3"
Test #17:
score: 0
Accepted
time: 749ms
memory: 244976kb
input:
29
output:
2
result:
ok 1 number(s): "2"
Test #18:
score: 0
Accepted
time: 780ms
memory: 244800kb
input:
31
output:
13
result:
ok 1 number(s): "13"
Test #19:
score: 0
Accepted
time: 806ms
memory: 244816kb
input:
37
output:
5
result:
ok 1 number(s): "5"
Test #20:
score: 0
Accepted
time: 794ms
memory: 244816kb
input:
41
output:
21
result:
ok 1 number(s): "21"
Test #21:
score: 0
Accepted
time: 872ms
memory: 244820kb
input:
60
output:
8
result:
ok 1 number(s): "8"
Test #22:
score: 0
Accepted
time: 1004ms
memory: 244796kb
input:
100
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 994ms
memory: 244756kb
input:
105
output:
41
result:
ok 1 number(s): "41"
Test #24:
score: 0
Accepted
time: 988ms
memory: 244816kb
input:
128
output:
31
result:
ok 1 number(s): "31"
Test #25:
score: 0
Accepted
time: 1012ms
memory: 244984kb
input:
130
output:
25
result:
ok 1 number(s): "25"
Test #26:
score: 0
Accepted
time: 1126ms
memory: 244808kb
input:
256
output:
52
result:
ok 1 number(s): "52"
Test #27:
score: 0
Accepted
time: 1128ms
memory: 244824kb
input:
290
output:
15
result:
ok 1 number(s): "15"
Test #28:
score: 0
Accepted
time: 1217ms
memory: 244948kb
input:
455
output:
104
result:
ok 1 number(s): "104"
Test #29:
score: 0
Accepted
time: 1247ms
memory: 244732kb
input:
512
output:
45
result:
ok 1 number(s): "45"
Test #30:
score: 0
Accepted
time: 1286ms
memory: 244796kb
input:
777
output:
35
result:
ok 1 number(s): "35"
Test #31:
score: 0
Accepted
time: 1311ms
memory: 244804kb
input:
707
output:
175
result:
ok 1 number(s): "175"
Test #32:
score: 0
Accepted
time: 1253ms
memory: 244976kb
input:
449
output:
13
result:
ok 1 number(s): "13"
Test #33:
score: 0
Accepted
time: 1263ms
memory: 245012kb
input:
573
output:
168
result:
ok 1 number(s): "168"
Test #34:
score: 0
Accepted
time: 1287ms
memory: 244788kb
input:
858
output:
49
result:
ok 1 number(s): "49"
Test #35:
score: 0
Accepted
time: 1093ms
memory: 245012kb
input:
230
output:
58
result:
ok 1 number(s): "58"
Test #36:
score: 0
Accepted
time: 1351ms
memory: 244744kb
input:
972
output:
117
result:
ok 1 number(s): "117"
Test #37:
score: 0
Accepted
time: 1318ms
memory: 245012kb
input:
844
output:
47
result:
ok 1 number(s): "47"
Test #38:
score: 0
Accepted
time: 1212ms
memory: 244732kb
input:
378
output:
37
result:
ok 1 number(s): "37"
Test #39:
score: 0
Accepted
time: 1205ms
memory: 244820kb
input:
423
output:
49
result:
ok 1 number(s): "49"
Test #40:
score: 0
Accepted
time: 1085ms
memory: 245020kb
input:
209
output:
20
result:
ok 1 number(s): "20"
Test #41:
score: 0
Accepted
time: 1734ms
memory: 244824kb
input:
5645
output:
338
result:
ok 1 number(s): "338"
Test #42:
score: 0
Accepted
time: 1462ms
memory: 244736kb
input:
2034
output:
249
result:
ok 1 number(s): "249"
Test #43:
score: 0
Accepted
time: 1783ms
memory: 244828kb
input:
6163
output:
206
result:
ok 1 number(s): "206"
Test #44:
score: 0
Accepted
time: 1757ms
memory: 244672kb
input:
6422
output:
346
result:
ok 1 number(s): "346"
Test #45:
score: 0
Accepted
time: 1402ms
memory: 244820kb
input:
1550
output:
40
result:
ok 1 number(s): "40"
Test #46:
score: 0
Accepted
time: 1806ms
memory: 244728kb
input:
6940
output:
674
result:
ok 1 number(s): "674"
Test #47:
score: 0
Accepted
time: 1489ms
memory: 244732kb
input:
2068
output:
157
result:
ok 1 number(s): "157"
Test #48:
score: 0
Accepted
time: 1745ms
memory: 245032kb
input:
6197
output:
594
result:
ok 1 number(s): "594"
Test #49:
score: 0
Accepted
time: 1792ms
memory: 244688kb
input:
6456
output:
913
result:
ok 1 number(s): "913"
Test #50:
score: 0
Accepted
time: 1908ms
memory: 244820kb
input:
8776
output:
423
result:
ok 1 number(s): "423"
Test #51:
score: 0
Accepted
time: 1610ms
memory: 244816kb
input:
3904
output:
281
result:
ok 1 number(s): "281"
Test #52:
score: 0
Accepted
time: 1605ms
memory: 244728kb
input:
4163
output:
230
result:
ok 1 number(s): "230"
Test #53:
score: 0
Accepted
time: 1655ms
memory: 244672kb
input:
4422
output:
631
result:
ok 1 number(s): "631"
Test #54:
score: 0
Accepted
time: 1678ms
memory: 245032kb
input:
4681
output:
95
result:
ok 1 number(s): "95"
Test #55:
score: 0
Accepted
time: 1901ms
memory: 244800kb
input:
8810
output:
835
result:
ok 1 number(s): "835"
Test #56:
score: 0
Accepted
time: 1613ms
memory: 244740kb
input:
3938
output:
350
result:
ok 1 number(s): "350"
Test #57:
score: 0
Accepted
time: 1929ms
memory: 244764kb
input:
9328
output:
373
result:
ok 1 number(s): "373"
Test #58:
score: 0
Accepted
time: 1617ms
memory: 244828kb
input:
4456
output:
932
result:
ok 1 number(s): "932"
Test #59:
score: 0
Accepted
time: 1653ms
memory: 244744kb
input:
4715
output:
476
result:
ok 1 number(s): "476"
Test #60:
score: 0
Accepted
time: 1838ms
memory: 245032kb
input:
7633
output:
591
result:
ok 1 number(s): "591"
Test #61:
score: 0
Accepted
time: 1528ms
memory: 244736kb
input:
2762
output:
263
result:
ok 1 number(s): "263"
Test #62:
score: 0
Accepted
time: 1883ms
memory: 244804kb
input:
8152
output:
465
result:
ok 1 number(s): "465"
Test #63:
score: 0
Accepted
time: 1520ms
memory: 244816kb
input:
3280
output:
157
result:
ok 1 number(s): "157"
Test #64:
score: 0
Accepted
time: 1576ms
memory: 245024kb
input:
3539
output:
79
result:
ok 1 number(s): "79"
Test #65:
score: 0
Accepted
time: 1820ms
memory: 244768kb
input:
7668
output:
905
result:
ok 1 number(s): "905"
Test #66:
score: 0
Accepted
time: 1838ms
memory: 244808kb
input:
7927
output:
357
result:
ok 1 number(s): "357"
Test #67:
score: 0
Accepted
time: 1860ms
memory: 244692kb
input:
8186
output:
543
result:
ok 1 number(s): "543"
Test #68:
score: 0
Accepted
time: 1568ms
memory: 245032kb
input:
3314
output:
306
result:
ok 1 number(s): "306"
Test #69:
score: 0
Accepted
time: 1570ms
memory: 244800kb
input:
3573
output:
69
result:
ok 1 number(s): "69"
Test #70:
score: 0
Accepted
time: 1779ms
memory: 244760kb
input:
6873
output:
667
result:
ok 1 number(s): "667"
Test #71:
score: 0
Accepted
time: 1481ms
memory: 244672kb
input:
2001
output:
134
result:
ok 1 number(s): "134"
Test #72:
score: 0
Accepted
time: 1831ms
memory: 244700kb
input:
7391
output:
477
result:
ok 1 number(s): "477"
Test #73:
score: 0
Accepted
time: 1473ms
memory: 244736kb
input:
2519
output:
267
result:
ok 1 number(s): "267"
Test #74:
score: 0
Accepted
time: 1538ms
memory: 244688kb
input:
2778
output:
162
result:
ok 1 number(s): "162"
Test #75:
score: 0
Accepted
time: 1546ms
memory: 244744kb
input:
3037
output:
282
result:
ok 1 number(s): "282"
Test #76:
score: 0
Accepted
time: 1536ms
memory: 244764kb
input:
3296
output:
458
result:
ok 1 number(s): "458"
Test #77:
score: 0
Accepted
time: 1793ms
memory: 244752kb
input:
7426
output:
214
result:
ok 1 number(s): "214"
Test #78:
score: 0
Accepted
time: 1492ms
memory: 244688kb
input:
2554
output:
102
result:
ok 1 number(s): "102"
Test #79:
score: 0
Accepted
time: 1800ms
memory: 244808kb
input:
7944
output:
283
result:
ok 1 number(s): "283"
Test #80:
score: 0
Accepted
time: 1778ms
memory: 244820kb
input:
6113
output:
121
result:
ok 1 number(s): "121"
Test #81:
score: 0
Accepted
time: 1927ms
memory: 244756kb
input:
10000
output:
917
result:
ok 1 number(s): "917"
Test #82:
score: 0
Accepted
time: 1927ms
memory: 244748kb
input:
9999
output:
470
result:
ok 1 number(s): "470"
Test #83:
score: 0
Accepted
time: 1878ms
memory: 244996kb
input:
9998
output:
1552
result:
ok 1 number(s): "1552"
Test #84:
score: 0
Accepted
time: 1961ms
memory: 244764kb
input:
9997
output:
538
result:
ok 1 number(s): "538"
Test #85:
score: 0
Accepted
time: 1949ms
memory: 244744kb
input:
9996
output:
193
result:
ok 1 number(s): "193"
Test #86:
score: 0
Accepted
time: 1894ms
memory: 244772kb
input:
9995
output:
624
result:
ok 1 number(s): "624"
Test #87:
score: 0
Accepted
time: 1917ms
memory: 244700kb
input:
9994
output:
481
result:
ok 1 number(s): "481"
Test #88:
score: 0
Accepted
time: 1939ms
memory: 244976kb
input:
9993
output:
617
result:
ok 1 number(s): "617"
Test #89:
score: 0
Accepted
time: 1901ms
memory: 245024kb
input:
9992
output:
433
result:
ok 1 number(s): "433"
Test #90:
score: 0
Accepted
time: 2012ms
memory: 244748kb
input:
9991
output:
425
result:
ok 1 number(s): "425"
Test #91:
score: 0
Accepted
time: 1929ms
memory: 244992kb
input:
9990
output:
509
result:
ok 1 number(s): "509"
Test #92:
score: 0
Accepted
time: 1993ms
memory: 244748kb
input:
9989
output:
808
result:
ok 1 number(s): "808"
Test #93:
score: 0
Accepted
time: 1940ms
memory: 245040kb
input:
9988
output:
734
result:
ok 1 number(s): "734"
Test #94:
score: 0
Accepted
time: 1903ms
memory: 244832kb
input:
9987
output:
922
result:
ok 1 number(s): "922"
Test #95:
score: 0
Accepted
time: 1953ms
memory: 244996kb
input:
9986
output:
1252
result:
ok 1 number(s): "1252"
Test #96:
score: 0
Accepted
time: 1969ms
memory: 244756kb
input:
9985
output:
378
result:
ok 1 number(s): "378"
Test #97:
score: 0
Accepted
time: 1942ms
memory: 244764kb
input:
9984
output:
472
result:
ok 1 number(s): "472"
Test #98:
score: 0
Accepted
time: 1977ms
memory: 244804kb
input:
9983
output:
363
result:
ok 1 number(s): "363"
Test #99:
score: 0
Accepted
time: 1950ms
memory: 245032kb
input:
9982
output:
1121
result:
ok 1 number(s): "1121"
Test #100:
score: 0
Accepted
time: 1907ms
memory: 244820kb
input:
9981
output:
261
result:
ok 1 number(s): "261"
Test #101:
score: 0
Accepted
time: 1835ms
memory: 244836kb
input:
9980
output:
228
result:
ok 1 number(s): "228"
Test #102:
score: 0
Accepted
time: 1460ms
memory: 244748kb
input:
1811
output:
2
result:
ok 1 number(s): "2"
Test #103:
score: 0
Accepted
time: 1703ms
memory: 244824kb
input:
5598
output:
14
result:
ok 1 number(s): "14"
Test #104:
score: 0
Accepted
time: 1474ms
memory: 244812kb
input:
2466
output:
33
result:
ok 1 number(s): "33"
Extra Test:
score: 0
Extra Test Passed