https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=509
這題是要找階層後尾部數過來低一個不為0的數,測資最大可能有10000階層肯定會爆 所以每乘1次要把尾數0去掉,最後再%100000
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
while(scn.hasNext()){
int n=scn.nextInt(),tot=1,index=0;
for(int i=2;i<=n;i++){
tot*=i;
while(tot%10==0)
tot/=10;
tot%=100000;
}
System.out.printf("%5d -> %d\n",n,tot%10);
}
}
/*
題目:Q568: Just the Facts
作者:1010
時間:西元 2016 年 8 月 */
}