結果

問題 No.314 ケンケンパ
ユーザー bayashiko_rbayashiko_r
提出日時 2019-01-03 21:16:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,103 bytes
コンパイル時間 3,166 ms
コンパイル使用メモリ 112,480 KB
実行使用メモリ 47,088 KB
最終ジャッジ日時 2024-05-03 02:34:04
合計ジャッジ時間 2,416 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 ms
17,280 KB
testcase_02 AC 27 ms
18,688 KB
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 27 ms
18,816 KB
testcase_07 AC 28 ms
18,816 KB
testcase_08 AC 27 ms
18,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program {
    static void Main(string[] args) {
        //入力
        ulong N = ulong.Parse(Console.ReadLine());

        //各係数に対する配列を用意する
        ulong[] an = new ulong[N];
        ulong[] bn = new ulong[N];
        ulong[] cn = new ulong[N];
        an[0] = 1;
        an[1] = 0;
        an[2] = 0;

        bn[0] = 0;
        bn[1] = 1;
        bn[2] = 0;

        cn[0] = 0;
        cn[1] = 0;
        cn[2] = 1;

        for (ulong i = 3; i < N; i++) {
            an[i] = an[i - 3] + an[i - 2];
            bn[i] = bn[i - 3] + bn[i - 2];
            cn[i] = cn[i - 3] + cn[i - 2];
        }


        //出力
        switch (N) {
            case 1:
                Console.WriteLine("1");
                break;
            case 2:
                Console.WriteLine("2");
                break;
            case 3:
                Console.WriteLine("2");
                break;
            default:
                Console.WriteLine((an[N - 1] + 2 * bn[N - 1] + 2 * cn[N - 1]) % (Math.Pow(10, 9) + 1));
                break;
        }
    }
}
0