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 |
其实这个算法有问题的,比如全是0的情况,然而似乎测试数据没有这东西╮(╯▽╰)╭In Reply To:无意间发现简单的算法! Posted by:lovexx at 2006-07-25 23:53:44 用这个代码可以AC,但是00000之类的情况就会判断错误 #include<iostream> #include<stdio.h> #include<cstring> #include<cmath> #include<string> #include<stack> #include<queue> #include<algorithm> using namespace std; int main() { string king; while(cin>>king) { int queen=king.length(); int temp=0; bool res=true; int mul=queen+1; for (int i=queen-1;i>=0;i--) { int result=(king[i]-'0')*mul+temp; int single=result-(result/10)*10; result-=single; if (single!=9) { res=false; break; } temp=result; temp/=10; } while(temp!=0) { int single=temp%10; if(single!=9) { res=false; break; } temp/=10; } if (res) cout<<king<<" is cyclic"<<endl; else cout<<king<<" is not cyclic"<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator