結果

問題 No.554 recurrence formula
ユーザー HomuhomuHomuhomu
提出日時 2020-04-20 04:37:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 484 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 66,932 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-16 00:31:43
合計ジャッジ時間 4,136 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;
using ull = unsigned long long;
#define Mod %1000000007

ull a(int n)
{
	if (n <= 1)
		return 1;

	if (n % 2 == 0)
	{
		ull am = 0;
		for (int i = n - 1; i > 0; i -= 2)
			am += a(i);
		return n * (am Mod);
	}
	else
	{
		ull am = 0;
		for (int i = n - 1; i > 0; i -= 2)
			am += a(i);
		return n * (am Mod);
	}
}

int main() 
{
	int n;
	cin >> n;

	cout << a(n)Mod << endl;

	return 0;
}
0