解题思路: 大数BigInteger的应用
注意事项:
参考代码:
import java.math.BigInteger; import java.util.Scanner; public class Main { private static BigInteger jie(BigInteger n) { BigInteger sum=BigInteger.ONE; for(BigInteger i=BigInteger.ONE;i.compareTo(n)<=0;i=i.add(BigInteger.ONE)) { sum=sum.multiply(i); } return sum; } public static void main(String []args) { Scanner in = new Scanner(System.in); BigInteger n =in.nextBigInteger(),m=in.nextBigInteger(),p=in.nextBigInteger(); BigInteger cha =jie(n).subtract(jie(m)); System.out.println(cha.mod(p)); in.close(); } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:608 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1294 |
众数问题 (C语言代码)浏览:821 |
WU-输入输出格式练习 (C++代码)浏览:1076 |
C语言训练-自由落体问题 (C语言代码)浏览:610 |
字符逆序 (C语言代码)浏览:455 |
矩阵乘方 (C语言代码)浏览:1022 |
星期判断机 (C语言代码)浏览:859 |
简单的a+b (C语言代码)浏览:572 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:608 |