使用java还不熟练,错误在于读入。应用in.hasNext()
代码
import java.text.ParseException; import java.text.SimpleDateFormat; import java.math.BigInteger; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) throws ParseException { Scanner in=new Scanner(System.in); while(in.hasNext()) { int n=in.nextInt(); BigInteger ans=new BigInteger("1"); for(int i=1;i<=n;i++) { BigInteger num = new BigInteger(String.valueOf(i)); ans=ans.multiply(num); } System.out.println(ans); } } }