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:一个奇异的程序(G++可过)In Reply To:一个奇异的程序(G++可过) Posted by:pdfpdf at 2006-05-20 00:11:43 不用long long 前的形态: #include<iostream> using namespace std; int main() { unsigned int a[5]={0,45,9045,1395495,189414495}; unsigned int b[6]={0,1,11,192,2893,38894}; int c[6]={0,1,10,100,1000,10000}; unsigned long n,i; for(cin>>n;n>0;n--) { cin>>i; int j; for(j=1;i>a[j];++j); //判是几位数 i-=a[j-1]; unsigned int s=b[j],f=c[j]; for(;i>s;++f) s+=b[j]+(f-c[j]+1)*j; int t=s-i; for(;t>0;--f,t-=j) if(f<c[j])j--; if(t!=0){ f+=1; if(f>c[j]*10-1)j++; t+=j; for(;t!=0;--t,f/=10); } cout<<f%10<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator