您的位置:首页 > 其它

51nod-1008 N的阶乘 mod P

2016-09-09 18:48 295 查看
https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1008

拿这题回顾了快速幂,a^b  % c    ==  (  a%c * b %c   )%c;

#include <iostream>
#include <stdio.h>
using namespace std;
long long sum=1;
int main()
{
int n,p;
cin>>n>>p;
for(int i=1;i<=n;i++)
{
sum*=i%p;
sum%=p;
}
cout<<sum<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: