結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2015-12-09 15:13:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 336 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 22,784 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-15 05:51:09 |
合計ジャッジ時間 | 1,031 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
#include <stdio.h>#define MOD 1000000007int main(void) {int n, i, dp[3] = {0, 1, 0};scanf("%d", &n);for(i = 1; i < n; i++) {int temp[3] = { dp[0], dp[1], dp[2] };dp[0] = ( temp[1] + temp[2] ) % MOD;dp[1] = temp[0];dp[2] = temp[1];}printf("%d\n", ( ( (dp[0] + dp[1]) % MOD ) + dp[2] ) % MOD );return 0;}