QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#338486 | #7225. The Kirakira Cycle | Kevin5307 | ML | 1356ms | 191320kb | C++20 | 575b | 2024-02-25 23:00:40 | 2024-02-25 23:00:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int lim=n*(n-1)/2;
vector<int> f(lim+1);
for(int i=1;i<=n;i++)
for(int j=i;j<=lim;j+=i)
f[j]-=i;
for(int i=1;i<=lim;i++)
f[i]+=f[i-1]+n;
int ans=0;
vector<int> vis(lim+1);
for(int i=0;i<=lim;i++)
{
vector<int> vec;
int p=i;
while(!vis[p])
{
vec.push_back(p);
vis[p]=1;
p=f[p];
}
reverse(vec.begin(),vec.end());
while(!vec.empty()&&vec.back()!=p)
vec.pop_back();
ans=max(ans,(int)vec.size());
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3520kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
10
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
43
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
4
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
5
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
6
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
7
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
8
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
11
output:
7
result:
ok 1 number(s): "7"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
13
output:
6
result:
ok 1 number(s): "6"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
17
output:
4
result:
ok 1 number(s): "4"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
19
output:
5
result:
ok 1 number(s): "5"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
23
output:
3
result:
ok 1 number(s): "3"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
29
output:
2
result:
ok 1 number(s): "2"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
31
output:
13
result:
ok 1 number(s): "13"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
37
output:
5
result:
ok 1 number(s): "5"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
41
output:
21
result:
ok 1 number(s): "21"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
60
output:
8
result:
ok 1 number(s): "8"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
100
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
105
output:
41
result:
ok 1 number(s): "41"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
128
output:
31
result:
ok 1 number(s): "31"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
130
output:
25
result:
ok 1 number(s): "25"
Test #26:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
256
output:
52
result:
ok 1 number(s): "52"
Test #27:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
290
output:
15
result:
ok 1 number(s): "15"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
455
output:
104
result:
ok 1 number(s): "104"
Test #29:
score: 0
Accepted
time: 4ms
memory: 4108kb
input:
512
output:
45
result:
ok 1 number(s): "45"
Test #30:
score: 0
Accepted
time: 4ms
memory: 5496kb
input:
777
output:
35
result:
ok 1 number(s): "35"
Test #31:
score: 0
Accepted
time: 7ms
memory: 5316kb
input:
707
output:
175
result:
ok 1 number(s): "175"
Test #32:
score: 0
Accepted
time: 3ms
memory: 3960kb
input:
449
output:
13
result:
ok 1 number(s): "13"
Test #33:
score: 0
Accepted
time: 5ms
memory: 4480kb
input:
573
output:
168
result:
ok 1 number(s): "168"
Test #34:
score: 0
Accepted
time: 7ms
memory: 6008kb
input:
858
output:
49
result:
ok 1 number(s): "49"
Test #35:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
230
output:
58
result:
ok 1 number(s): "58"
Test #36:
score: 0
Accepted
time: 14ms
memory: 6760kb
input:
972
output:
117
result:
ok 1 number(s): "117"
Test #37:
score: 0
Accepted
time: 8ms
memory: 6116kb
input:
844
output:
47
result:
ok 1 number(s): "47"
Test #38:
score: 0
Accepted
time: 2ms
memory: 3676kb
input:
378
output:
37
result:
ok 1 number(s): "37"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
423
output:
49
result:
ok 1 number(s): "49"
Test #40:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
209
output:
20
result:
ok 1 number(s): "20"
Test #41:
score: 0
Accepted
time: 841ms
memory: 127648kb
input:
5645
output:
338
result:
ok 1 number(s): "338"
Test #42:
score: 0
Accepted
time: 68ms
memory: 19324kb
input:
2034
output:
249
result:
ok 1 number(s): "249"
Test #43:
score: 0
Accepted
time: 1058ms
memory: 151312kb
input:
6163
output:
206
result:
ok 1 number(s): "206"
Test #44:
score: 0
Accepted
time: 1138ms
memory: 164208kb
input:
6422
output:
346
result:
ok 1 number(s): "346"
Test #45:
score: 0
Accepted
time: 38ms
memory: 12376kb
input:
1550
output:
40
result:
ok 1 number(s): "40"
Test #46:
score: 0
Accepted
time: 1356ms
memory: 191320kb
input:
6940
output:
674
result:
ok 1 number(s): "674"
Test #47:
score: 0
Accepted
time: 63ms
memory: 19888kb
input:
2068
output:
157
result:
ok 1 number(s): "157"
Test #48:
score: 0
Accepted
time: 1041ms
memory: 153200kb
input:
6197
output:
594
result:
ok 1 number(s): "594"
Test #49:
score: 0
Accepted
time: 1094ms
memory: 166104kb
input:
6456
output:
913
result:
ok 1 number(s): "913"
Test #50:
score: -100
Memory Limit Exceeded
input:
8776
output:
423