Resource limit
Time limit: 1.0s Memory limit: 256.0MB
Question description
Given N and Len, output n! Len bit at the end.
Input format
one line two positive integers n and len.
output format
One -line string represents the answer. The length is not enough to make up the front zero replenishment.
Sample input
6 5
Sample output
00720
Data scale and agreement
n<=30, len<=10。
packageTenth Simulation;
import java.math.BigInteger;
import java.util.Scanner;
public classsteps{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int len = sc.nextInt();
sc.close();
BigInteger num1 = new BigInteger(n+"");
for (int i = 2; i <n; i++) {
BigInteger num2 = new BigInteger(i+"");
num1=num1.multiply(num2);
}
String s = num1+"";
if(s.length()>len){
s=s.substring(s.length()-len);
}
else{
while(s.length()<len){
s="0"+s;
}
}
System.out.println(s);
}
}