Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

C++代码

Posted by freelark at 2016-11-23 15:52:16 on Problem 1012
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(void)
{
	int k, s, j, m, n;
	int a[15] = {};
	while (cin >> k)
	{		
		if (k == 0) break;
		m = k;
		n = 2 * k;
		if (!a[k])
		{
			for (;; m++)
			{
				s = 0;
				for (j = 0; j <k; j++)
				{
					s = (s + m - 1) % (n - j); //s是每次删除的位置
					if (s < k) break;
				}
				if (j == k) break;
			}
			a[k] = m;
		}		
		cout << a[k] << endl;
	}
	system("pause");
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator