#include #include #include #define ll long long using namespace std; //x!を10^9+7で割った余り ll Factrial[400010]; //(x!)^-1=(x!)^mod-2 ll FactInv[100010]; ll mod = 1000000007; vector v; void makeFactrial(); void makeFactInv(); ll powmod(int a); int main(){ int N; makeFactrial(); cout << Factrial[N] << endl; return 0; } void makeFactrial(){ Factrial[0] = 1; for(int i=1;i<400000;i++){ Factrial[i] = (i * Factrial[i-1]) % mod; } } void makeFactInv(){ for(int i=0;i<100000;i++){ FactInv[i] = powmod(Factrial[i]); } } ll powmod(int a){ int ret=1; for(int i=mod;i>0;i -= (i&-i)){ v.push_back(log2(i&-i)); } int vmax = v[v.size()-1]; int a_2_mod[vmax]; a_2_mod[0] = a%mod; for(int i=1;i<=vmax;i++){ a_2_mod[i] = (a_2_mod[i-1]*a_2_mod[i-1])%mod; } for(int i=0;i