天天看點

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

水題;

先打個暴搞的發現9位以下的無解,

九位的有八組解;

然後後面的任取都是合法的;

原先寫了個大數。。。

後來發現自己傻了。

附上代碼:

int main(){
    while(cin>>n){
    if(n<9)cout<<0<<endl;
    else {
        //f(n).output();
        if(n==9)printf("8\n");
        else {
            printf("72");
            for(int i=0;i<n-10;i++)printf("0");
            printf("\n");
        }
    }}
    return 0;
}
           

真相原來如此簡單!

繼續閱讀