#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;}
[2016-05-09][51nod][1008 N的阶乘 mod P]
原文:http://www.cnblogs.com/qhy285571052/p/a05ea631a23371459f59618cbbe68aef.html