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

我用纯模拟过的。。。新手。。别BS我。。

Posted by talentdcy at 2011-12-04 12:06:44 on Problem 1019
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
__int64 digits[70001],sum[70001];
long a[7]={0,0,9,189,2889,38889,488889};
long b[6]={0,9,99,999,9999,99999};
int main()
{
    __int64 i,N,flag,dig,ans,temp,k,num;
    memset(digits,0,sizeof(digits));
    memset(sum,0,sizeof(sum));
    for(i=1;i<=70000;i++)
    {
                         digits[i]=digits[i-1]+1;
                         if(i>=10) digits[i]++;
                         if(i>=100) digits[i]++;
                         if(i>=1000) digits[i]++;
                         if(i>=10000) digits[i]++;
    }
    for(i=1;i<=70000;i++)
    sum[i]=sum[i-1]+digits[i];
    scanf("%I64d",&N);
    for(k=1;k<=N;k++)
    {
                     scanf("%I64d",&num);
                     if(num==1)
                     {
                               printf("1\n");
                               continue;
                     }
                     for(i=1;i<=70000;i++)
                     if(num>sum[i]&&num<=sum[i+1])
                     {
                                                  flag=i;
                                                  break;
                     }
                     temp=num-sum[flag];
                     for(i=0;i<=6;i++)
                     if(temp>a[i]&&temp<=a[i+1])
                     {
                                                dig=i;
                                                temp=temp-a[i];
                                                break;
                     }
                     num=(temp-1)/dig+1+b[dig-1];
                     temp=(temp-1)%dig+1;
                     ans=1; 
                     if(dig>temp)
                     for(i=1;i<=dig-temp;i++)
                     ans*=10;
                     num=(num/ans)%10;
                     printf("%I64d\n",num);
    }
    system("pause");
    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