博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
51 Nod 1008 N的阶乘 mod P【Java大数乱搞】
阅读量:7066 次
发布时间:2019-06-28

本文共 809 字,大约阅读时间需要 2 分钟。

基准时间限制:1 秒 空间限制:131072 KB 分值: 0
输入N和P(P为质数),求N! Mod P = ? (Mod 就是求模 %)
 
例如:n = 10, P = 11,10! = 3628800
3628800 % 11 = 10
Input
两个数N,P,中间用空格隔开。(N < 10000, P < 10^9)
Output
输出N! mod P的结果。
Input示例
10 11
Output示例
10
题目链接:
分析:学了简单的Java,就来体验了一波Java的爽感,Java大法真的好啊!
下面给出AC代码:
1 import java.math.BigInteger; 2 import java.util.Scanner; 3  4  5 public class sss { 6  7     /** 8      * @param args 9      */10     public static void main(String[] args) {11         // TODO Auto-generated method stub12         Scanner in=new Scanner(System.in);13         BigInteger sum=BigInteger.ONE;14         int n;15         n=in.nextInt();16         BigInteger p=in.nextBigInteger();17         for(int i=1;i<=n;i++)18             sum=sum.multiply(BigInteger.valueOf(i));19         System.out.println(sum.remainder(p));20     }21 }

 

转载地址:http://ndxll.baihongyu.com/

你可能感兴趣的文章
国家级期刊发表要求注意事项
查看>>
C文件操作
查看>>
观察转小写的操作-字符函数
查看>>
Oracle查询访问同一表的两个以上索引(二)
查看>>
office 2016 下载地址
查看>>
Go语言之调试
查看>>
Go语言之 unsafe 包之内存布局
查看>>
Spring Cloud Config 入门
查看>>
rhce第二天笔记
查看>>
oneproxy中间件架构及注意事项
查看>>
phpweb解析不当加上传漏洞
查看>>
CentOS自动挂载NTFS分区的U盘或者移动硬盘
查看>>
2018-2019-1 20165226 20165310 20165315 实验二 固件程序设计
查看>>
安装windows后grub的恢复
查看>>
android学习总结(20120721)
查看>>
安装rrdtool时候的报错configure: error: Please fix the library issues listed above and try again....
查看>>
创建一个10G可用空间的RAID5
查看>>
snmp安装
查看>>
elasticsearch常用操作命令
查看>>
设置sqlplus提示符
查看>>