涉及知识点:
solution:
- (祝大家劳动节快乐,所以出了一道简单的题(别被题面吓住了))
- (有个坑点,0的阶乘等于1,我也是做了这个题才知道的)
- (我们写出[0,3]对应的答案:)
- (0!!! = 1!! = 1! = 1)
- (1!!! = 1!! = 1! = 1)
- (2!!! = 2!! = 2! = 2)
- (3!!! = 6!! = 720! = 很大很大的数..)
- (如果n大于等于3,其实答案就是0)
- (我们可以想一下,n!对n取模,其实就是0,因为含有n这个因子)
- (n>=4,n!!必然是一个大于mod的数,所以一定也包含mod这个因子)
std:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n,mod;
cin>>n>>mod;
ll ans=1;
if(n == 1 || n == 0){
ans = 1%mod;
}
else if(n == 2){
ans = n%mod;
}
else if( n == 3){
for(int i=1;i<=720;i++){
ans *= i;
ans %= mod;
}
}
else{
ans = 0;
}
cout<<ans<<endl;
return 0;
}