SGU 107. 987654321 problem

107. 987654321 problem

time limit per test: 0.5 sec. 
memory limit per test: 4096 KB

For given number N you must output amount of N-digit numbers, such, that last digits of their square is equal to 987654321.

Input

Input contains integer number N (1<=N<=106)

Output

Write answer to the output.

Sample Input

8

Sample Output

0

一个数平方的最后N位数只有这个数的最后N位数决定.。。。。。。。


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    int n;

while(cin>>n)
{
    if(n<9)
        cout<<0<<endl;
    else if(n==9)
        cout<<8<<endl;
    else if(n==10)
        cout<<72<<endl;
    else
    {
        n-=10;
        printf("72");
        while(n--)
        {
            printf("0");
        }
        cout<<endl;
    }
}
    return 0;
}
* This source code was highlighted by YcdoiT. ( style: Codeblocks )


原文地址:https://www.cnblogs.com/CKboss/p/3350899.html