QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#338482#7225. The Kirakira CycleKevin5307RE 0ms3512kbC++20572b2024-02-25 22:57:522024-02-25 22:57:52

Judging History

你现在查看的是最新测评结果

  • [2024-02-25 22:57:52]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3512kb
  • [2024-02-25 22:57:52]
  • 提交

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;
}

詳細信息

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

output:


result: