結果
問題 |
No.554 recurrence formula
|
ユーザー |
![]() |
提出日時 | 2017-08-12 00:44:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 609 bytes |
コンパイル時間 | 2,018 ms |
コンパイル使用メモリ | 158,336 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 22:36:34 |
合計ジャッジ時間 | 2,002 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for(int i = 0; i < (n); i++) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) typedef long long ll; int n; ll MOD = 1000000007; ll a[100005]; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> n; ll s1 = 1, s2 = 0; a[1] = 1; for (int i = 2; i <= n; i++) { if (i & 1) { a[i] = i * s2 % MOD; s1 = (s1 + a[i]) % MOD; } else { a[i] = i * s1 % MOD; s2 = (s1 + a[i]) % MOD; } } cout << a[n] << endl; return 0; }