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 |
为啥我的c++ ac了,G++就wa了类,大牛帮忙看看啊,附代码#include<stdio.h> long p=1,n[200001]={0,1},sum[300001]={0,1}; int weishu(long m) { int num=0; while(m>0) { num++; m=m/10; } return num; } int main() { int t=0; long long i,j=2,k; for(i=2;i<=300000&&sum[i-1]>=0;i++) { t=weishu(i); j=i; for(k=t;k>=1;k--) { n[p+k]=j%10; j/=10; } p=p+t; sum[i]=sum[i-1]+p; } scanf("%d",&t); while(t--) { scanf("%lld",&j); for(k=0;k<i-1;k++) { if(sum[k]>=j) { j=j-sum[k-1]; break; } } if(k==i-1)j=j-sum[i-2]; printf("%lld\n",n[j]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator