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

Re:1019-谁能帮我看看为什么总是WA啊

Posted by wpc0000 at 2006-12-27 22:31:56
In Reply To:1019-谁能帮我看看为什么总是WA啊 Posted by:Ocirlin at 2005-10-26 15:35:03
#include <stdio.h>

typedef __int64 longint;
int main()
{
	longint task;
	longint n;
	longint i,j,k,l;
	longint st[10];
	scanf("%I64d",&task);
	while (task--)
	{
		scanf("%I64d",&n);
		i = 0; j = 0; l = 0;
		while (l < n)
		{
			i++;
			if ( i < 10) k = 1;
			else if (i < 100) k = 2;
			else if (i < 1000) k = 3;
			else if (i < 10000) k = 4;
			else if (i < 100000) k = 5;
			else if (i < 1000000) k = 6;
			j += k;
			l += j;
		}
		l -= j;
		n -= l;
		i = 0; j = 0;
		while (j < n)
		{
			i++;
			if ( i < 10) k = 1;
			else if (i < 100) k = 2;
			else if (i < 1000) k = 3;
			else if (i < 10000) k = 4;
			else if (i < 100000) k = 5;
			else if (i < 1000000) k = 6;
			j += k;
		}
		j -= k;
		n -= j;
		k = 0;
		while (i)
		{
			st[k++] = i % 10;
			i /= 10;
		}
		printf("%I64d\n",st[k-n]);
	}
	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