結果
| 問題 |
No.554 recurrence formula
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2017-08-11 22:22:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 371 bytes |
| コンパイル時間 | 502 ms |
| コンパイル使用メモリ | 64,000 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 20:57:46 |
| 合計ジャッジ時間 | 1,216 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <iostream>
using namespace std;
const int mod = 1000000007;
int n, dp[100009];
int main() {
cin >> n;
dp[1] = 1;
int s0 = 0, s1 = 1;
for (int i = 2; i <= n; i++) {
if (i % 2 == 0) {
dp[i] = 1LL * i * s1 % mod;
s0 = (s0 + dp[i]) % mod;
}
else {
dp[i] = 1LL * i * s0 % mod;
s1 = (s1 + dp[i]) % mod;
}
}
cout << dp[n] << endl;
return 0;
}
square1001