結果
問題 | No.554 recurrence formula |
ユーザー |
![]() |
提出日時 | 2017-08-11 22:35:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 1,505 ms |
コンパイル使用メモリ | 166,084 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 21:18:05 |
合計ジャッジ時間 | 2,222 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(int i=0;i<N;++i) typedef long long int LL; LL N; LL one = 1, two, ans; int main() { in >> N; ans = one; for (LL i = 2; i <= N; ++i) { if (i % 2 == 0) { ans = i*one; ans %= MOD; two += ans; two %= MOD; } else { ans = i*two; ans %= MOD; one += ans; one %= MOD; } } out << ans << std::endl; return 0; }