結果
| 問題 | No.554 recurrence formula |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-11 23:30:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 569 ms |
| コンパイル使用メモリ | 79,848 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-12 22:00:20 |
| 合計ジャッジ時間 | 1,283 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 16 |
ソースコード
#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])%mod);
memo[i] %= mod;
}
cout << memo[n] << endl;
return 0;
}