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 xijunlee93 at 2013-03-24 09:19:26 on Problem 1019
恶心的代码如下:
#include<iostream>
#include<fstream>
#include<stdlib.h>
using namespace std;
long s[40001];
int main()
{
    ifstream infile;
    ofstream outfile;
    infile.open("data.in",ios::in);
    outfile.open("data.out",ios::out);
    long k,i,t,n,temp,j,count,num,l,data[100];
    long long ans=0;
    s[1]=1;
    for (k=2;k<=32000;k++)
    {
       if (k<10)
         s[k]=s[k-1]+1;
       if (k>=10&&k<100)
         s[k]=s[k-1]+2;
       if (k>=100&&k<1000)
         s[k]=s[k-1]+3;
       if (k>=1000&&k<10000)
         s[k]=s[k-1]+4;
       if (k>=10000&&k<100000)
         s[k]=s[k-1]+5;
    }
    infile>>t;
    for (i=1;i<=t;i++)
    {
       infile>>n;
       ans=0;
       k=1;
       while(ans<n)
       {
          ans+=s[k];k++;
       }
       k--;
       ans-=s[k];
       ans=n-ans;
       count=0;
       j=1;
       while(j<=k&&count<ans)
       {
          temp=j;l=0;
          while(temp>0&&count<ans)
          {temp/=10;l++;}
          if (count+l<ans)
          count+=l;
          else
          {num=j;break;}
          j++;
       }
       memset(data,0,sizeof(data));
       j=1;
       while(num>0)
       {data[j++]=num%10;num/=10;}
       j--;
       outfile<<data[j-(ans-count)+1]<<endl;
    }
    infile.close();
    outfile.close();
    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