107. 987654321 problem
time limit per test: 0.25 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 == 9时有八个解,大于9的解由乘法原理易算
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int n;
int main()
{ scanf("%d",&n); if( n <= ) {
printf("0\n"); } else if(n == ) {
printf("8\n");
} else {
printf("");
for(int i = ; i < n; i++) {
printf("0\n");
}
}
return ;
}