結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2021-01-26 20:29:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 1,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 1,468 ms |
コンパイル使用メモリ | 166,572 KB |
実行使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2024-06-23 18:58:35 |
合計ジャッジ時間 | 2,294 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll a[1000005]; ll b[1000005]; ll c[1000005]; ll const mod = 1e9+7; int main(){ int n; cin >> n; a[2] = 1; b[2] = 1; c[2] = 0; int ans = 0; if(n==1) ans = 1; if(n==2) ans = 2; if(n>=3){ for(int i = 3; i <= n; i++){ a[i] = (b[i-1]+c[i-1])%mod; b[i] = c[i-1]%mod; c[i] = a[i-1]%mod; } ans = (a[n] + b[n] + c[n])%mod; ans = (ans+mod)%mod; } cout << ans << endl; return 0; }