poj1047 数论
来源:互联网 发布:行政区域数据 编辑:程序博客网 时间:2024/06/02 16:23
题意:输入一个数(该整数的长度为2~60),判断该数是否是循环数。设该整数的长度为n,所谓循环数,是指该数分别乘以1~n,得到的数发生循环。
算法:循环数规律,若某数a是循环数, 则a*(n+1)所得的结果全是9
#include <iostream>#include <string.h>using namespace std;char str[100];int main(){while (cin >> str){bool flag = true;int n = strlen(str) + 1;int b = 0;// 进位 for (int i=n-2; i>=0; i--){int a = (str[i]-'0')*n + b;b = a / 10;int c = a % 10;if (c != 9){flag = false;break;}}(flag)? cout << str << " is cyclic" << endl : cout << str << " is not cyclic" << endl;}}
0 0
- poj1047 数论
- poj1047
- poj1047
- poj1047
- poj1047
- POJ1047
- poj1047 高精度
- POJ1047解题报告
- poj1047(高精度加)
- 【poj1047】循环数
- poj1047 2010.2.17
- poj1047(树形dp)
- 数论
- 数论
- 数论
- 数论
- 数论
- 数论
- javascript中的Left,Top,Width,Height等相关属性汇总
- sqlite3函数sqlite3_exec
- 第四周 时间
- window.location.hash详解
- 视频网络协议
- poj1047 数论
- 字体问题
- select自定义属性值
- js 正则表达式/g对exec()测试结果的影响
- ZOJ 2417 Lowest Bit
- Code Forces 645C Enduring Exodus
- Gson之手动方式
- 基于FileReader实现的图片网页本地浏览
- sql server 修改表架构