[2016-05-09][51nod][1008 N的阶乘 mod P]
时间:2016-05-09 21:21:54 星期一
题目编号:[2016-05-09][51nod][1008 N的阶乘 mod P]
题目大意:输入N和P(P为质数),求N! Mod P = ? (Mod 就是求模 %)
分析:直接算…
#include<stdio.h>using namespace std;typedef long long ll;int main(){ll n,p,ans = 1;scanf("%lld%lld",&n,&p);for(int i = 1 ; i <= n ; ++i){ans = (ans * i) % p;}printf("%d\n",ans);return 0;}
浙公网安备 33010602011771号