41 lines
700 B
Java
41 lines
700 B
Java
package LanQiaoOJ;
|
||
|
||
import java.math.BigInteger;
|
||
import java.util.Scanner;
|
||
|
||
/*
|
||
* 问题描述
|
||
满足N!的末尾恰好有K个0的最小的N是多
|
||
少?
|
||
如果这样的N不存在输出一1。
|
||
输入格式
|
||
一个整数K。
|
||
输出格式
|
||
一个整数代表答案。*/
|
||
public class 求阶乘 {
|
||
|
||
public static void main(String[] args) {
|
||
Scanner sc=new Scanner(System.in);
|
||
long k=sc.nextInt();//0的个数
|
||
for(long i=2;i<1e18;i++) {
|
||
if(Fun(i)==k) {
|
||
System.out.print(i);
|
||
break;
|
||
}else if(Fun(i)>k) {
|
||
System.out.print(-1);
|
||
return;
|
||
}
|
||
}
|
||
|
||
}
|
||
public static long Fun(long n) {
|
||
long ans=0;
|
||
while(n>0) {
|
||
//因数中有1个5就有1个0,即计算5的个数
|
||
ans=ans+n/5;
|
||
n=n/5;
|
||
}
|
||
return ans;
|
||
}
|
||
}
|