Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA成神了

Posted by Pro_zq at 2009-08-19 22:50:47 on Problem 2183
附上源码,希望大牛能指点啊,不胜感激

#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator