結果

問題 No.314 ケンケンパ
ユーザー piyoko_212piyoko_212
提出日時 2015-12-25 17:39:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 331 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 34,076 KB
実行使用メモリ 26,848 KB
最終ジャッジ日時 2023-10-19 03:41:00
合計ジャッジ時間 1,172 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,800 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 14 ms
14,560 KB
testcase_19 AC 28 ms
26,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         int a;scanf("%d",&a);
      |               ~~~~~^~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long dp[1100000][3];
int main(){
	int a;scanf("%d",&a);
	dp[0][0]=1;
	for(int i=1;i<=a;i++){
		dp[i][0]=(dp[i-1][1]+dp[i-1][2])%mod;
		dp[i][1]=(dp[i-1][0])%mod;
		dp[i][2]=dp[i-1][1];
	}
	printf("%lld\n",(dp[a][0]+dp[a][1]+dp[a][2])%mod);
}
0