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

偷偷粘下代码

Posted by orangelegend at 2008-09-26 21:49:09 on Problem 1019
#include <stdio.h>

int inc(__int64 k)
{
	int len = 0;
	while(k != 0)
	{
		len++;
		k = k / 10;
	}
	return len;
}

int main()
{
	__int64 i,j,n,k,len;

	scanf("%I64d",&n);
	while (n--)
	{
		scanf("%I64d",&i);
		j = len = 0;
		k = 1;
		while (j < i)		//找到那一串数	
		{
			len += inc(k);
			k++;
			j += len;
		}
		
		j -= len;
		k = 1;
		while (j < i)          //找到那串数里的那个数
		{
			j += inc(k);
			k++;
		}
		k--;
		j -= inc(k);
		len = inc(k) - (i - j);
		while(len--)           //找到那个数里的那个数字
			k = k / 10;

		printf("%I64d\n",k % 10);
	}

	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