POJ 2183

模拟题

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int p[1000000];

int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		memset(p,0,sizeof(p));
		int i;
		for(i=1;;i++){
			n/=10;
			n%=10000;
			n*=n;
			n%=1000000;
			if(p[n]>0){
				break;
			}
			p[n]=i;
		}
		printf("%d %d %d\n",n,i-p[n],i);
	}
	return 0;
}

  

posted @ 2014-09-14 21:56  chenjunjie1994  阅读(142)  评论(0编辑  收藏  举报