| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WA成神了附上源码,希望大牛能指点啊,不胜感激
#include <stdio.h>
int main()
{
int cutNum; //Middle 4 digits
long cutSquare; //Middle square
int inputNum; //输入的数
int check[30000]; //这个不知道应该定多大
int i, j; //循环变量
char isFind = 0; //标记变量
scanf("%d", &inputNum);
cutNum = inputNum / 10 % 10000;
i = 0;
while(1)
{
cutSquare = cutNum * cutNum;
check[i] = cutSquare % 10000000;
for(j = 0; j < i; ++j)
{
if(check[j] == check[i])
{
isFind = 1;
break;
}
}
if(isFind)
{
printf("%d %d %d", check[i], i - j, i + 1);
break;
}
cutNum = check[i] / 10 % 10000;
i++;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator