QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#338485 | #7225. The Kirakira Cycle | Kevin5307 | WA | 1ms | 3768kb | C++20 | 575b | 2024-02-25 23:00:20 | 2024-02-25 23:00:20 |
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=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.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: 1ms
memory: 3576kb
input:
10
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
43
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
1
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'