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 |
请教高手,为什么会超时啊,答案应该没问题。谢了。#include<stdio.h> void main() { int n; while(scanf("%d",&n)!=EOF) { int i,j,count=0; int s[1005]={0}; for(i=2;i<=n;i++) { if(i%2) { for(j=0;j<=count;j++) { s[j]*=2; } s[0]=s[0]-1; for(j=0;j<=count;j++) { s[j+1]+=s[j]/10; s[j]=s[j]%10; } if(s[j]!=0)s[++count]=s[j]; } else { for(j=0;j<=count;j++) { s[j]*=2; } s[0]=s[0]+1; for(j=0;j<=count;j++) { s[j+1]+=s[j]/10; s[j]=s[j]%10; } if(s[j]!=0)s[++count]=s[j]; } } for(i=count;i>=0;i--)printf("%d",s[i]); printf("\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator