解题思路: 大数
注意事项:
参考代码:
import java.math.BigInteger; import java.util.Scanner; public class Main { private static void fab(int n,int m) { BigInteger nj=BigInteger.ONE,mj=BigInteger.ONE,nmj=BigInteger.ONE; for(BigInteger i=BigInteger.ONE;i.compareTo(BigInteger.valueOf(n))<=0;i=i.add(BigInteger.ONE)) { nj=nj.multiply(i); } for(BigInteger i=BigInteger.ONE;i.compareTo(BigInteger.valueOf(m))<=0;i=i.add(BigInteger.ONE)) { mj=mj.multiply(i); } for(BigInteger i=BigInteger.ONE;i.compareTo(BigInteger.valueOf(n-m))<=0;i=i.add(BigInteger.ONE)) { nmj=nmj.multiply(i); } BigInteger res =nj.divide(mj.multiply(nmj)); System.out.println(res); } public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()) { int m=in.nextInt(),n=in.nextInt(); fab(m,n); } in.close(); } }
0.0分
5 人评分