[url="http://ace.delos.com/usacoprob2?a=WDIfgI5VP1P&S=fact4"]英文原题[/url] [url="http://www.wzoi.org/usaco/12%5C503.asp"]中文题译[/url]
大意:找N!的第一个非0位的值。
一个字:水。
大意:找N!的第一个非0位的值。
一个字:水。
/*
ID: blackco3
TASK: fact4
LANG: C++
*/
#include <iostream>
using namespace std;
int main() {
freopen("fact4.in", "r", stdin);
freopen("fact4.out", "w", stdout);
int n;
cin >> n ;
int remain = 1 ;
for(int i=2; i<=n; i++ ) {
remain *= i;
while( !(remain%10) )
remain /= 10;
remain %= 10000;
}
cout << (remain%10) << endl ;
return 0;
}