WA 了好几次,只保留一位数不够。
代码如下:
1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 long long a[10001]; 7 8 int main() 9 { 10 long long n, i, t; 11 a[0]=1; 12 for (i=1; i<=10000; i++) 13 { 14 t=a[i-1]*i; 15 while(t%10 == 0) 16 t/=10; 17 a[i]=t%100000; //就是这,a[i]=t%10; 18 } 19 while(cin >> n) 20 printf("%5lld -> %lld\n", n, a[n]%10); 21 return 0; 22 }