結果
| 問題 |
No.554 recurrence formula
|
| コンテスト | |
| ユーザー |
treeone
|
| 提出日時 | 2017-08-12 00:40:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 530 bytes |
| コンパイル時間 | 1,470 ms |
| コンパイル使用メモリ | 157,680 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-12 22:36:13 |
| 合計ジャッジ時間 | 1,996 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
signed main(){
int n;
cin >> n;
int odd = 1, even = 0;
int now = 1;
rep(i, 2, n + 1){
if(i % 2 == 0){
now = i * odd % mod;
(even += now) %= mod;
}else{
now = i * even % mod;
(odd += now) %= mod;
}
}
cout << now << endl;
}
treeone