結果
問題 | No.1277 級数入り級数 |
ユーザー | 57tggx |
提出日時 | 2020-10-21 10:35:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 1,483 bytes |
コンパイル時間 | 1,030 ms |
コンパイル使用メモリ | 66,552 KB |
最終ジャッジ日時 | 2025-01-15 12:12:08 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 50 |
ソースコード
#include <iostream> using lint = long long; template<class T, long long MOD> class Modint{ T val; public: Modint(T val = 0) : val(val) {} operator T(){ return val; } Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; } Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; } Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; } void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];} Modint &operator/=(Modint a){ a.inverse(); return *this *= a; } friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; } friend Modint operator+(Modint a, const Modint &b){ return a += b; } friend Modint operator-(Modint a, const Modint &b){ return a -= b; } friend Modint operator*(Modint a, const Modint &b){ return a *= b; } friend Modint operator/(Modint a, const Modint &b){ return a /= b; } friend std::istream &operator>>(std::istream &is, Modint &a){ is >> a.val; a.val %= MOD; if(a.val < 0) a.val += MOD; return is; } friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; } }; using Mint = Modint<lint, 1000000007ll>; int main(){ lint n; std::cin >> n; Mint fact = 1; for(lint i = 2; i <= n; ++i){ fact *= Mint(i); } std::cout << 1 << std::endl << fact << std::endl << n << std::endl; }