解题思路:  大数

注意事项:

参考代码:

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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区