結果

問題 No.554 recurrence formula
ユーザー Homuhomu
提出日時 2020-04-20 04:37:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 484 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 67,136 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-10-06 08:28:42
合計ジャッジ時間 4,403 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 TLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

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