QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#338482 | #7225. The Kirakira Cycle | Kevin5307 | RE | 0ms | 3512kb | C++20 | 572b | 2024-02-25 22:57:52 | 2024-02-25 22:57:52 |
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]--;
for(int i=1;i<=lim;i++)
f[i]+=f[i-1]+n;
int ans=0;
vector<int> vis(lim+1);
for(int i=1;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.size()&&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: 0ms
memory: 3512kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: -100
Runtime Error
input:
10