結果
問題 | No.1275 綺麗な式 |
ユーザー | 57tggx |
提出日時 | 2020-09-21 15:48:41 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,607 bytes |
コンパイル時間 | 984 ms |
コンパイル使用メモリ | 71,640 KB |
実行使用メモリ | 7,568 KB |
最終ジャッジ日時 | 2024-07-21 07:54:42 |
合計ジャッジ時間 | 9,382 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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
7,332 KB |
testcase_31 | AC | 4 ms
7,524 KB |
testcase_32 | AC | 11 ms
7,456 KB |
testcase_33 | AC | 4 ms
7,424 KB |
testcase_34 | AC | 8 ms
7,468 KB |
testcase_35 | AC | 4 ms
7,468 KB |
testcase_36 | AC | 6 ms
7,568 KB |
testcase_37 | AC | 6 ms
7,452 KB |
testcase_38 | AC | 23 ms
7,496 KB |
testcase_39 | AC | 230 ms
7,336 KB |
testcase_40 | AC | 4 ms
7,420 KB |
testcase_41 | AC | 227 ms
7,300 KB |
testcase_42 | AC | 4 ms
7,408 KB |
testcase_43 | AC | 4 ms
7,452 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> #include <sys/stat.h> #include <sys/mman.h> 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, 1000000007>; int main(){ struct stat stat; fstat(0, &stat); char *input = static_cast<char *>(mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, 0, 0)); enum { num_a, num_b, num_n, } state = num_a; Int a = 0, b = 0, n = 0; for(int i = 0; i < stat.st_size; ++i){ if(state == num_a){ if(isdigit(input[i])){ a = a * 10 + (input[i] - '0'); }else if(input[i] == ' '){ state = num_b; }else{ return 0; } }else if(state == num_b){ if(isdigit(input[i])){ b = b * 10 + (input[i] - '0'); }else if(input[i] == '\n'){ state = num_n; }else{ return 0; } }else if(state == num_n){ if(isdigit(input[i])){ n = n * 10 + (input[i] - '0'); }else if(input[i] == '\n'){ break; }else{ return 0; } } } 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; }