結果

問題 No.314 ケンケンパ
ユーザー LeonardoneLeonardone
提出日時 2015-12-08 09:02:01
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 86 ms / 1,000 ms
コード長 471 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 46,036 KB
最終ジャッジ日時 2024-04-21 01:15:11
合計ジャッジ時間 2,688 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
43,520 KB
testcase_01 AC 80 ms
41,944 KB
testcase_02 AC 78 ms
39,808 KB
testcase_03 AC 75 ms
40,320 KB
testcase_04 AC 80 ms
42,312 KB
testcase_05 AC 75 ms
39,936 KB
testcase_06 AC 77 ms
42,232 KB
testcase_07 AC 74 ms
42,104 KB
testcase_08 AC 73 ms
42,068 KB
testcase_09 AC 73 ms
39,936 KB
testcase_10 AC 74 ms
40,064 KB
testcase_11 AC 75 ms
40,192 KB
testcase_12 AC 74 ms
41,968 KB
testcase_13 AC 75 ms
42,072 KB
testcase_14 AC 75 ms
42,064 KB
testcase_15 AC 77 ms
43,520 KB
testcase_16 AC 78 ms
46,036 KB
testcase_17 AC 78 ms
43,392 KB
testcase_18 AC 82 ms
45,812 KB
testcase_19 AC 86 ms
43,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder My Practice
// author: Leonardone @ NEETSDKASU

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 解説読後
// http://yukicoder.me/problems/882/editorial

process.stdin.on('data', function(chunk) {
    var n = parseInt(chunk.toString());
    
    var a = 0, b = 1, c = 0, ta;
    
    while (--n > 0) {
        ta = (b + c) % 1000000007;
        c = b;
        b = a;
        a = ta;
    }
    
    console.log((a + b + c) % 1000000007);
});
0