sgu107. 987654321 problem 简单打表 难度:0
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
思路:打表找规律
WA 原因:打表速度太慢,我以为打完了,9之间只有4个
应用时:思路3min 打表30min
#include <cstdio> using namespace std; int n; int main(){ while(scanf("%d",&n)==1){ if(n<9)puts("0"); else if(n==9)puts("8"); else{ printf("72"); for(int i=10;i<n;i++){ putchar('0'); } putchar('\n'); } } return 0; }