POJ 1047 Round and Round We Go
生活随笔
收集整理的這篇文章主要介紹了
POJ 1047 Round and Round We Go
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://poj.org/problem?id=1047
按照某大牛總結的一條規律,對于數N,若N為循環的則有N*(length(N)+1)=99....99, (length(N)個9),length(N)為N的位數,含前導0。應該還是簡單的...
還有POJ是什么時候換網址的...= =b
#include<iostream> #include<string> using namespace std; bool fun(string str) {int n=str.length()+1;int i,up=0,temp=0;for(i=n-2;i>=0;i--){temp=(int)(str[i]-'0');if((temp*n+up)%10!=9) return false;up=(temp*n+up)/10;}return true; } int main() {string str1;while(cin>>str1){if(fun(str1)){cout<<str1<<" is cyclic"<<endl; }else{cout<<str1<<" is not cyclic"<<endl;}}return 0; }轉載于:https://www.cnblogs.com/wotata/archive/2011/03/16/1986180.html
總結
以上是生活随笔為你收集整理的POJ 1047 Round and Round We Go的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 由于检索用户的本地应用程序数据路径时出错
- 下一篇: Button的点击事件