poj2183

简单题

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

#define maxn 1000000

int n;
int vis[maxn];

int main()
{
//freopen("t.txt", "r", stdin);
scanf("%d", &n);
memset(vis,
-1, sizeof(vis));
int i = 0;
while (1)
{
if (vis[n] != -1)
break;
vis[n]
= i;
n
= n / 10 % 10000;
n
= n * n;
n
%= 1000000;
i
++;
}
printf(
"%d %d %d\n", n, i - vis[n], i);
return 0;
}
posted @ 2011-07-31 16:23  金海峰  阅读(143)  评论(0编辑  收藏  举报