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

为什么gcc就RTE,c就AC?我自己在本地用gcc试了1到13的数据也正常啊,求教!

Posted by underchange at 2009-07-20 12:03:12 on Problem 1012
#include <stdio.h>

#define MAXK 20

int stored[MAXK];

int main()
{
	int ans, k, t, i, j, j1;
	for (i=1; i<MAXK; i++) stored[i] = 0;
	scanf("%d", &k);
	while (k != 0)
	{
		if (stored[k] != 0) printf("%d\n", stored[k]);
		else
		{
			ans = 2;
			while (1)
			{
				t = 2 * k;
				j = (ans - 1) % t;
				for (i=0; i<k; i++)
				{
					if (j < k) break;
					j1 = (j + (ans - 1) % (t - 1) + 1) % t;
					if (j1 > j) j = j1 - 1; else j = j1;
					t --;
				}
				if (i == k)
				{
					stored[k] = ans;
					printf("%d\n", ans);
					break;
				}
				ans ++;
			}
		}
		scanf("%d", &k);
	}
	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