文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>POJ 1047 Round and Round We Go

POJ 1047 Round and Round We Go

时间:2011-03-16  来源:watana

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;
}
相关阅读 更多 +
排行榜 更多 +
打螺丝高手

打螺丝高手

模拟经营 下载
解救火柴人计划安卓版

解救火柴人计划安卓版

体育竞技 下载
鸡生化精英安卓版

鸡生化精英安卓版

飞行射击 下载