結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2018-10-24 16:38:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 38 ms / 1,000 ms |
コード長 | 725 bytes |
コンパイル時間 | 735 ms |
コンパイル使用メモリ | 60,536 KB |
実行使用メモリ | 26,752 KB |
最終ジャッジ日時 | 2024-11-19 05:27:57 |
合計ジャッジ時間 | 1,644 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:29: warning: iteration 3 invokes undefined behavior [-Waggressive-loop-optimizations] 26 | rep(i,4) (ans += dp[N][i]) %= MOD; | ~~~~~~~^ main.cpp:8:34: note: within this loop 8 | #define rep(i,N) for(int(i)=0;(i)<(N);++(i)) | ~~~^~~~ main.cpp:26:5: note: in expansion of macro ‘rep’ 26 | rep(i,4) (ans += dp[N][i]) %= MOD; | ^~~
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;using ll = long long;const int MOD = 1e9+7;#define put(n) cout<<(n)<<endl#define rep(i,N) for(int(i)=0;(i)<(N);++(i))#define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i))#define all(v) (v).begin() , (v).end()#define rall(v) (v).rbegin() , (v).rend()#define pb(n) push_back(n)int a[1010],b[1010];//,dp[1010][1010];ll dp[1001000][3];int main(){int N; cin >> N;dp[1][1] = 1;for(int i=1;i<=N;++i){(dp[i][2] += dp[i-1][1]) %= MOD;(dp[i][1] += dp[i-1][0]) %= MOD;(dp[i][0] += dp[i-1][2] + dp[i-1][1]) %= MOD;}ll ans = 0;rep(i,4) (ans += dp[N][i]) %= MOD;cout << ans << endl;}