51Nod--1008
来源:互联网 发布:mac安装虚拟机教程 编辑:程序博客网 时间:2024/06/13 00:39
1008 N的阶乘 mod P
基准时间限制: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
解题思路:模运算的性质
源代码:
#include<iostream>#include<stdio.h>#include<math.h>using namespace std;int main(){ long long a,b,i,result; scanf("%lld%lld",&a,&b); result = 1; for(i = 1; i <= a; i++) { result = (result % b * i % b)%b; } printf("%lld\n",result); return 0;}
1 0
- 51Nod--1008
- (51nod)1008
- 51Nod 1008
- 51Nod
- 51Nod
- 51nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 装逼专用
- 【BZOJ2342】双倍回文,manacher+并查集优化
- spring mvc controller中获取属性文件(properties)的值
- 数学水题
- JavaScript定时器
- 51Nod--1008
- 欢迎使用CSDN-markdown编辑器
- BeanShell in JMeter(Performance Test) —— JMeter中的Beanshell使用
- php 解析xml 的四种方法(转)
- 阅读优秀代码是提高开发人员修为的一种捷径
- PHP入门
- @ResponseBody
- [usaco月赛]梦幻王国
- QT程序打包出错:缺少dll或者应用程序无法启动