⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2244.txt

📁 北大ACM题目例程 详细的解答过程 程序实现 算法分析
💻 TXT
字号:


#define debug 0
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define NMAX 10
#define INF 1000000001
int ans[151]={0};
void init()
{
	int i,j,a,n,k;
	for(i=3;i<=150;i++)
	{
		for(j=2;j<=10000;j++)
		{
			a=0;
			for(n=i-1;n>0;n--)
			{
				a=(a+j-1)%n;
				if(a==0)
				{
					n--;
					break;
				}
			}
			if(n==0)
			{
				ans[i]=j;
				break;
			}
		}
	}
}
main()
{
#if debug 	
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int n;
	init();
	scanf("%d",&n);
	while(n)
	{
		printf("%d\n",ans[n]);
		scanf("%d",&n);
	}

#if debug
	fclose(stdin);
	fclose(stdout);
#endif;
	return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -