| ||||||||||
| 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:Why wrong?In Reply To:Why wrong? Posted by:ecjtuyushuangjian at 2006-09-09 20:59:16 > #include<iostream>
> #include<stdio.h>
> #include<string>
> using namespace std;
> char ch[61];
> int main()
> {int i,flag,c[61],l,sh[61],L,j,a[3],f;
> while(scanf("%s",ch)!=EOF)
> {flag=f=1;
> l=strlen(ch);L=l+1;
> for(i=0;i<l;i++)
> {if(ch[i]!='0'){f=0;break;}
> }//cout<<f<<endl;
> if(f==1)goto pp;
> for(i=1;i<=l;i++)c[i]=ch[i-1]-'0';
> a[1]=L/10;a[2]=L%10;
> for(i=0;i<=l+1;i++)sh[i]=0;
> for(i=1;i<=l;i++)
> for(j=1;j<3;j++)
> sh[i+j-1]+=a[j]*c[i];
> for(i=1;i<=l+1;i++)
> {if(sh[i]>9)
> {sh[i-1]+=sh[i]/10;
> sh[i]%=10;
> }
> }
> for(i=2;i<=l+1;i++)
> {//cout<<"sh["<<i<<"]="<<sh[i]<<endl;
> if(sh[i]!=9){flag=0;break;}
> }
> pp:;
> if(flag==0)cout<<ch<<" is not cyclic"<<endl;
> else cout<<ch<<" is cyclic"<<endl;
> }//while
> return 0;
> }
> /*
> Sample Input
>
>
> 142857
> 142856
> 142858
> 01
> 0588235294117647
>
>
> Sample Output
>
>
> 142857 is cyclic
> 142856 is not cyclic
> 142858 is not cyclic
> 01 is not cyclic
> 0588235294117647 is cyclic
>
>
> Source
>
> */
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator