結果

問題 No.1275 綺麗な式
ユーザー 57tggx57tggx
提出日時 2020-09-21 14:47:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,858 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 70,560 KB
実行使用メモリ 7,556 KB
最終ジャッジ日時 2023-09-28 13:17:13
合計ジャッジ時間 9,411 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
7,364 KB
testcase_31 AC 3 ms
7,348 KB
testcase_32 AC 11 ms
7,352 KB
testcase_33 AC 4 ms
7,444 KB
testcase_34 AC 7 ms
7,352 KB
testcase_35 AC 4 ms
7,416 KB
testcase_36 AC 5 ms
7,508 KB
testcase_37 AC 5 ms
7,356 KB
testcase_38 AC 23 ms
7,364 KB
testcase_39 AC 226 ms
7,556 KB
testcase_40 AC 4 ms
7,348 KB
testcase_41 AC 228 ms
7,412 KB
testcase_42 AC 3 ms
7,348 KB
testcase_43 AC 3 ms
7,436 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0