結果

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

ソースコード

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],ans[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]/(i-2)));
		memo[i] %=  mod;
	}
	cout << memo[n] << endl;
	return 0;
}
0