问题 E : 坤哥的难题v(循环)
来源:互联网 发布:网络出版物 编辑:程序博客网 时间:2024/05/16 06:42
题目描述
八百年才能出现的好事接二连三的发生在了坤哥头上,可是你们总是让他的好事泡汤。坤哥不愿意了,他决心考考你们,先给你一个六位数,然后曲这个六位数中间四位,然后在让这个四位数平方,得到的这个数在取它的后六位。如此反复,一直做到找到循环节。例如给你65554这个数;
Num 4digits square 6digits or fewer
65554 5555 30858025 858025
858025 5802 33663204 663204
663204 6320 39942400 942400
942400 4240 17977600 977600
977600 7760 60217600 217600 <—— |
217600 1760 3097600 97600 |
97600 9760 95257600 257600 |
257600 5760 33177600 177600 |
177600 7760 60217600 217600 —— |
输入格式
多组测试样例。一个六位数。
输出
输出循环节的第一个数,循环节的大小和需要几次才能发现循环节。
样例输入
655554
样例输出
217600 4 9
#include <cstdio>#include <cstring>#include <map>#include <iostream>#include <cmath>#include <algorithm>using namespace std;int t;int Map[1000007];int main(){ while(cin>>t) { memset(Map,0,sizeof(Map)); Map[t]=1; int num=0; int k=0; while(true) { t/=10; t%=10000; t*=t; t%=1000000; if(Map[t]!=0) { num++; cout<<t<<" "<<num-Map[t]<<" "<<num<<endl; break; } Map[t]=++num; } }return 0;}
#include <cstdio>#include <cstring>#include <map>#include <iostream>#include <cmath>#include <algorithm>using namespace std;int t;int Map[1000007];int main(){ while(cin>>t) { memset(Map,0,sizeof(Map)); Map[t]=1; int num=0; int k=0; while(true) { t/=10; t%=10000; t*=t; t%=1000000; if(Map[t]!=0) { num++; cout<<t<<" "<<num-Map[t]<<" "<<num<<endl; break; } Map[t]=++num; } }return 0;}
0 0
- 问题 E : 坤哥的难题v(循环)
- SDJZU--E坤哥的难题
- (精度)hpu 问题 E: 搬砖难题
- 问题 E : 坤哥的难题 (题目本来觉得很难,但是数据很水,居然简单的for就AC)
- Problem E: 类的初体验(V)
- 工商银行拥抱互联网的“e-难题”
- E - V
- sdjzu坤哥的难题
- vue规定v-for循环的次数
- Euler 的面(Face,F)、顶(Vertex,V)、棱(Edge,E)公式
- android的Log详解(Log.v Log.d Log.i Log.w Log.e)
- 生活中的数学问题(数学家的难题)
- FZU 1686 神龙的难题(重复覆盖问题)
- 蚂蚁的难题(异或最大值问题)
- L.O.V.E
- V + = e不等价于 v = v + e
- v+=e不等于v=v+e
- v-for循环 重复数据无法添加问题
- Myeclipse报AutoBuilder错误解决办法
- 跟我一起写Makefile(五):使用变量
- OGRE1.8.1+MyGUI3.2.0+VS2010 编译配置图文详解
- 数组作为查询的参数
- ogre+mygui配置
- 问题 E : 坤哥的难题v(循环)
- 问题 F : 8(字符串处理)
- 【迭代器模式-Iterator】
- JS函数调用的四种方法
- TI-Davinci开发系列之八x-loader工作流程分析
- 2.插入排序——折半插入排序
- [: 11: y: unexpected operator问题
- 问题 A : 人生三大幻觉(组合数学)
- 链表指针