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

rt很多次了,实在没有办法,请各位指点

Posted by magephilia at 2006-05-31 10:49:45 on Problem 2591
把数组全部改大了,还用了__int64,但就是rt。
请各位帮忙看看,同时求AC的程序...实在是太不甘心了
#include <stdio.h>

const long max=10000000;

int main()
{
	long j,k,m;
	__int64 num[max+5];
	__int64 form[3][3];//form[i][0]表示指向第几个num,form[i][1]存值
	num[0]=1;
	form[0][0]=0;
	form[0][1]=3;
	form[1][0]=0;
	form[1][1]=4;
	k=0;
	for (j=1;j<=max;j++)
	{
		if (form[0][1]<form[1][1])
		{
			k++;
			num[k]=form[0][1];
			form[0][0]++;
			form[0][1]=num[form[0][0]]*2+1;
		}
		else if (form[0][1]>form[1][1])
		{
			k++;
			num[k]=form[1][1];
			form[1][0]++;
			form[1][1]=num[form[1][0]]*3+1;
		}
		else
		{
			k++;
			num[k]=form[1][1];
			form[0][0]++;
			form[0][1]=num[form[0][0]]*2+1;
			form[1][0]++;
			form[1][1]=num[form[1][0]]*3+1;
		}
	}
	while (scanf("%ld",&m) != EOF)
	{
		printf("%I64d\n",num[--m]);
	}

	return 1;
}

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