在第一个样例中,由于 2! = 22!=2,所以 2!!! = (((2!)!)!) = ((2!)!) = (2!) = 22!!!=(((2!)!)!)=((2!)!)=(2!)=2。2模了6324还是2!
所以答案为2。
CODE:
#include<cstdio> #define ll long long using namespace std; int main() { ll n,mod,ans=1; scanf("%lld%lld",&n,&mod); if(n>=4) { printf("0"); return 0; } if(n==0) { printf("%lld",1%mod); return 0; } if(n==1) { printf("%lld",1%mod); return 0; } if(n==2) { printf("%lld",2%mod); return 0; } if(n==3) { for(int i=1;i<=720;i++) ans=(ll) (ans*i)%mod; printf("%lld",ans); return 0; } }