結果

問題 No.554 recurrence formula
ユーザー nksk38
提出日時 2017-08-11 23:29:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 725 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 78,976 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 22:00:03
合計ジャッジ時間 1,327 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

ll mod = ll(1e9 + 7);
ll memo[100010];
int n; 

int main()
{
	cin >> n;
	memo[1] = 1;
	memo[2] = 2;
	memo[3] = 6;
	memo[4] = 28;
	memo[5] = 150;
	for (int i = 6; i <= n; i++) {
		memo[i] = i*(memo[i - 1] + memo[i - 2]);
		memo[i] %=  mod;
	}
	cout << memo[n] << endl;
	return 0;
}
0