結果
問題 |
No.314 ケンケンパ
|
ユーザー |
|
提出日時 | 2015-12-07 05:54:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 846 bytes |
コンパイル時間 | 686 ms |
コンパイル使用メモリ | 58,000 KB |
実行使用メモリ | 16,824 KB |
最終ジャッジ日時 | 2024-09-14 18:04:28 |
合計ジャッジ時間 | 5,108 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 16 |
ソースコード
// yukicoder My Practice // author: Leonardone @ NEETSDKASU #include <iostream> #include <algorithm> using namespace std; typedef long long ll; typedef unsigned long long ull; const ll MD = 1000000007LL; const ull UMD = 1000000007ULL; ll cmb(ll n, ll c) { ll r = 1LL; c = min(c, n - c); for (ll i = 1; i <= c; i++) { r *= n--; r /= i; } return r % MD; } ull fnc(ll n) { ll c = 0LL; ll i = 0LL; if (n > 0LL && (n & 1LL)) { i = 1LL; n -= 3LL; } ll d = n >> 1; while (d >= 0LL) { c = (c + cmb(d + i, i)) % MD; i += 2LL; d -= 3LL; } return ull(c); } void solve() { ll n; cin >> n; ull ans = (((fnc(n) + fnc(n - 1)) % UMD) + fnc(n - 2)) % UMD; cout << ans << endl; } int main() { solve(); return 0; }