QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#338485#7225. The Kirakira CycleKevin5307WA 1ms3768kbC++20575b2024-02-25 23:00:202024-02-25 23:00:20

Judging History

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

  • [2024-02-25 23:00:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3768kb
  • [2024-02-25 23:00:20]
  • 提交

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

詳細信息

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'