結果

問題 No.314 ケンケンパ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-28 11:58:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 1,000 ms
コード長 576 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 71,528 KB
実行使用メモリ 76,232 KB
最終ジャッジ日時 2023-08-18 08:42:30
合計ジャッジ時間 5,765 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
76,112 KB
testcase_01 AC 122 ms
55,452 KB
testcase_02 AC 122 ms
55,456 KB
testcase_03 AC 120 ms
55,904 KB
testcase_04 AC 120 ms
55,456 KB
testcase_05 AC 120 ms
55,836 KB
testcase_06 AC 119 ms
55,716 KB
testcase_07 AC 121 ms
55,808 KB
testcase_08 AC 122 ms
55,716 KB
testcase_09 AC 123 ms
56,064 KB
testcase_10 AC 122 ms
55,900 KB
testcase_11 AC 122 ms
55,848 KB
testcase_12 AC 120 ms
55,588 KB
testcase_13 AC 122 ms
55,616 KB
testcase_14 AC 119 ms
55,452 KB
testcase_15 AC 118 ms
55,776 KB
testcase_16 AC 121 ms
55,744 KB
testcase_17 AC 125 ms
57,820 KB
testcase_18 AC 139 ms
64,312 KB
testcase_19 AC 161 ms
76,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int mod = (int)(Math.pow(10,9))+7;
        long [] ken = new long [N+1];
        long [] kenken = new long [N+1];
        long [] pa = new long [N+1];
        ken[1]=1;
        for(int i=2; i<=N; i++){
            ken[i]=pa[i-1];
            kenken[i]=ken[i-1];
            pa[i]=(ken[i-1]+kenken[i-1])%mod;
        }
        long ans = (ken[N]+kenken[N]+pa[N])%mod;
        System.out.println(ans);
    }
}
0