結果

問題 No.554 recurrence formula
ユーザー makonagixmakonagix
提出日時 2017-08-28 00:57:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 57,800 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 04:04:43
合計ジャッジ時間 1,897 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

long sumodd = 1;
long sumeven = 0;
int main(){
	long n;
	cin >> n;
	for (long i = 2; i <= n; i++) {
		if (i % 2 == 0) {
			long an = (i*sumodd) % 1000000007;
			if (i == n) {
				cout << an << endl;
				break;
			}
			sumeven = (sumeven + an) % 1000000007;
		}
		else {
			long an = (i*sumeven) % 1000000007;
			if (i == n) {
				cout << an << endl;
				break;
			}
			sumodd = (sumodd + an) % 1000000007;
		}
	}
	return 0;
}
0