結果

問題 No.793 うし数列 2
ユーザー CuriousFairy315CuriousFairy315
提出日時 2019-02-22 21:59:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 858 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 67,152 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 02:15:06
合計ジャッジ時間 1,151 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std; // 575

const int MOD = 1000000007;

long pow(long a, long b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	if (b == 2) return a * a % MOD;
	return pow(pow(a, b >> 1), 2) * pow(a, b & 1) % MOD;
}
int main() {
	long N;
	cin >> N;
	cout << 333333336L * (pow(2, N + 2) * pow(5, N) % MOD - 1) % MOD;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、数列とみて考えてみる
これはE(1)=13, E(N)=10E(N-1)+3 mod 10^9+7なので行列累乗でえいでは
というわけで突っ込んだ、終わり https://www.wolframalpha.com/input/?i=f(1)%3D13,+f(N%2B1)%3D10f(N)%2B3
*/
0