結果
問題 | No.1275 綺麗な式 |
ユーザー |
|
提出日時 | 2020-09-21 14:47:34 |
言語 | C++17 (gcc 11.2.0 + boost 1.78.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,858 bytes |
コンパイル時間 | 471 ms |
使用メモリ | 8,376 KB |
最終ジャッジ日時 | 2023-02-20 15:35:51 |
合計ジャッジ時間 | 19,090 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | AC | 4 ms
8,324 KB |
testcase_31 | AC | 5 ms
8,312 KB |
testcase_32 | AC | 11 ms
7,616 KB |
testcase_33 | AC | 4 ms
8,316 KB |
testcase_34 | AC | 8 ms
7,588 KB |
testcase_35 | AC | 4 ms
8,308 KB |
testcase_36 | AC | 6 ms
7,724 KB |
testcase_37 | AC | 6 ms
8,240 KB |
testcase_38 | AC | 24 ms
8,324 KB |
testcase_39 | AC | 226 ms
7,592 KB |
testcase_40 | AC | 4 ms
7,668 KB |
testcase_41 | AC | 227 ms
8,256 KB |
testcase_42 | AC | 4 ms
8,252 KB |
testcase_43 | AC | 4 ms
7,656 KB |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
ソースコード
#include <iostream> template<class T, T MOD> class Modint{ T val; public: Modint(T val = 0) : val(val % MOD + (val >= 0 ? 0 : MOD)) {} 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::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; } }; using Int = long long; using Mint = Modint<Int, 1000000007ll>; int main(){ Int a, b, n; std::cin >> a >> b >> n; Mint array[512345]; for(Int i = 0; i <= n / 2; ++i) array[i] = 1; { Mint tmp = 1; for(Int i = 0; i <= n / 2; ++i){ array[i] *= tmp; tmp *= Mint(b); } } { Mint tmp = n % 2 ? a : 1; Mint square = Mint(a) * Mint(a); for(Int i = n / 2; i >= 0; --i){ array[i] *= tmp; tmp *= square; } } { Mint tmp = 1; for(Int i = 0; i < n; ++i){ if(i % 2 == 0) array[i / 2] *= tmp; tmp *= Mint(n - i); tmp /= Mint(i + 1); } } Mint ans = 0; for(Int i = 0; i <= n / 2; ++i){ // std::cout << array[i] << std::endl; ans += array[i]; } std::cout << ans * Mint(2) << std::endl; }