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 |
为什么老是Output Limit Exceeded ,求大神指点#include<iostream> #include<stdio.h> #include<cstring> using namespace std; #define Max 300 char string1[7],string2[7]; int an1[6],an2[6]; int an3[Max+10],Result[Max+10],an4[Max+10]; int main() { int Num,N; while((scanf("%s%d",string1,&N))!=EOF) { memset(an1,0,sizeof(an1)); memset(an2,0,sizeof(an2)); memset(an3,0,sizeof(an3)); memset(an4,0,sizeof(an4)); memset(Result,0,sizeof(Result)); int pos=0; int Num1; for(int i=0;i<6;i++) { if(string1[i]=='.'){pos=1;continue;} string2[i-pos]=string1[i]; } string2[5]='\0'; for(int i=0;i<5;i++) an1[i]=string2[4-i]-'0'; for(pos=0;pos<5;pos++) if(an1[pos]!=0)break; int pob; for(pob=5;pob>=0;pob--) if(an1[pob]!=0||pob==0)break; for(int i=pos,j=0;i<=pob;i++,j++) an3[j]=an2[j]=an1[i]; Num1=pob-pos+1; //cout<<"Num1="<<Num1<<endl; for(pos=0;pos<6;pos++) if(string1[pos]=='.')break; for(pob=5;pob>=0;pob--) if(string1[pob]=='.'||string1[pob]!='0')break; Num=(pob-pos)*N; for(int k=0;k<N-1;k++) { memset(an4,0,sizeof(an4)); for(int i=0;i<Num1;i++) { for(int j=0;j<Max+10;j++) an4[i+j]+=an3[j]*an2[i]; for(int j=0;j<Max+9;j++) if(an4[j]>9){an4[j+1]=an4[j+1]+an4[j]/10;an4[j]=an4[j]%10;} cout<<"第"<<k<<" "<<i<<"次:"; for(int j=0;j<Max+10;j++) cout<<an4[j]; cout<<endl; } for(int j=0;j<Max+10;j++) an3[j]=an4[j]; } if(N==1) { for(int i=0;i<Num1;i++) { an4[i]=an2[i]; } } if(Num!=0) { for(int i=0;i<Num;i++) Result[i]=an4[i]; Result[Num]=-1; for(int i=Num+1;i<Max+10;i++) Result[i]=an4[i-1]; } else { for(int i=0;i<Max+10;i++) Result[i]=an4[i]; } for(pos=Max+9;pos>=0;pos--) if(pos==0||Result[pos]!=0)break; for(int i=pos;i>=0;i--) { if(Result[i]==-1)cout<<"."; else cout<<Result[i]; } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator