这题经过仔细的枚举,发现就是n的阶乘,于是瞬间打代码,错,结果是因为没有mod 1e+9 + 7,于是再打代码,对了,于是决定写题解。
代码:
#include<bits/stdc++.h>
using namespace std;
const unsigned long long mod=1e+9+7;
int n;long long s=1;
int main(){
cin>>n;
for(int i=1;i<=n;++i){s*=i;s%=mod;}
cout<<s<<endl;
return 0;
}


京公网安备 11010502036488号