結果

問題 No.533 Mysterious Stairs
ユーザー bolabola110bolabola110
提出日時 2017-06-26 14:11:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 205 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 3,438 ms
コンパイル使用メモリ 77,596 KB
実行使用メモリ 116,336 KB
最終ジャッジ日時 2024-04-15 01:53:10
合計ジャッジ時間 8,778 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
116,104 KB
testcase_01 AC 158 ms
116,268 KB
testcase_02 AC 160 ms
116,272 KB
testcase_03 AC 159 ms
116,176 KB
testcase_04 AC 158 ms
116,320 KB
testcase_05 AC 161 ms
116,084 KB
testcase_06 AC 161 ms
116,296 KB
testcase_07 AC 159 ms
116,316 KB
testcase_08 AC 156 ms
116,000 KB
testcase_09 AC 155 ms
116,184 KB
testcase_10 AC 158 ms
116,268 KB
testcase_11 AC 158 ms
115,872 KB
testcase_12 AC 160 ms
116,044 KB
testcase_13 AC 156 ms
115,872 KB
testcase_14 AC 158 ms
116,020 KB
testcase_15 AC 157 ms
116,100 KB
testcase_16 AC 161 ms
116,292 KB
testcase_17 AC 159 ms
116,208 KB
testcase_18 AC 157 ms
116,200 KB
testcase_19 AC 158 ms
116,064 KB
testcase_20 AC 172 ms
116,004 KB
testcase_21 AC 172 ms
116,116 KB
testcase_22 AC 170 ms
115,248 KB
testcase_23 AC 202 ms
116,168 KB
testcase_24 AC 205 ms
116,044 KB
testcase_25 AC 173 ms
115,932 KB
testcase_26 AC 198 ms
116,336 KB
testcase_27 AC 167 ms
115,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
public class ex2{
   public static void main(String args[]){
     Scanner inp=new Scanner(System.in);
     int n=inp.nextInt();
     long[][] a=new long[4][2000000];
     a[1][1]=1;
     a[2][2]=1;
     a[3][3]=1;
     a[2][3]=1;
     a[1][3]=1;
     long mod=1000000007;
     if (n>=4)
     for(int i=4;i<=n;i++){
       a[1][i]=(a[2][i-1]+a[3][i-1])%mod;
       a[2][i]=(a[1][i-2]+a[3][i-2])%mod;
       a[3][i]=(a[2][i-3]+a[1][i-3])%mod;
     }
     System.out.println((((a[1][n]+a[2][n])%mod)+a[3][n])%mod);
   }
}
0