結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-24 03:22:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 410 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 17,152 KB |
最終ジャッジ日時 | 2024-10-04 05:12:38 |
合計ジャッジ時間 | 1,250 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> int MOD=1000000007; int dp[4][1000010]; int main(){ memset(dp,0,sizeof(dp)); dp[1][1]=1; dp[2][2]=1; dp[3][3]=1; int n; scanf("%d",&n); for(int i=1;i<n;i++){ for(int j=1;j<=3;j++){ for(int k=1;k<=3;k++){ if(j==k)continue; dp[k][i+k]=(dp[k][i+k]+dp[j][i])%MOD; } } } int ans=(dp[1][n]+dp[2][n])%MOD; ans=(ans+dp[3][n])%MOD; printf("%d\n",ans); }