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
8Sample Output
0
#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; } |