| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:1019-谁能帮我看看为什么总是WA啊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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator