結果

問題 No.533 Mysterious Stairs
ユーザー くれちーくれちー
提出日時 2017-06-24 18:23:15
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,464 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 117,172 KB
実行使用メモリ 27,368 KB
最終ジャッジ日時 2024-04-14 23:42:10
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
27,228 KB
testcase_01 AC 29 ms
25,324 KB
testcase_02 WA -
testcase_03 AC 29 ms
25,332 KB
testcase_04 AC 30 ms
25,136 KB
testcase_05 AC 29 ms
25,320 KB
testcase_06 AC 29 ms
27,096 KB
testcase_07 AC 29 ms
25,140 KB
testcase_08 AC 29 ms
25,304 KB
testcase_09 AC 30 ms
27,092 KB
testcase_10 AC 29 ms
25,044 KB
testcase_11 AC 29 ms
25,068 KB
testcase_12 AC 29 ms
27,352 KB
testcase_13 AC 28 ms
25,328 KB
testcase_14 AC 29 ms
23,088 KB
testcase_15 AC 30 ms
25,340 KB
testcase_16 AC 29 ms
25,324 KB
testcase_17 AC 29 ms
27,088 KB
testcase_18 AC 29 ms
25,052 KB
testcase_19 AC 30 ms
27,216 KB
testcase_20 AC 33 ms
25,316 KB
testcase_21 AC 33 ms
25,196 KB
testcase_22 AC 40 ms
25,136 KB
testcase_23 AC 56 ms
25,048 KB
testcase_24 AC 57 ms
27,216 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

#pragma warning disable IDE0011
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] line;

    public void R(char sep = ' ') { line = Console.ReadLine().Split(sep); idx = 0; }
    public string S => line[idx++];
    public string[] Ss => line.Skip(idx++).ToArray();
    public char C => char.Parse(line[idx++]);
    public char[] Cs => line.Skip(idx++).Select(char.Parse).ToArray();
    public int I => int.Parse(line[idx++]);
    public int[] Is => line.Skip(idx++).Select(int.Parse).ToArray();
    public long L => long.Parse(line[idx++]);
    public long[] Ls => line.Skip(idx++).Select(long.Parse).ToArray();
    public double F => double.Parse(line[idx++]);
    public double[] Fs => line.Skip(idx++).Select(double.Parse).ToArray();
    public decimal D => decimal.Parse(line[idx++]);
    public decimal[] Ds => line.Skip(idx++).Select(decimal.Parse).ToArray();
    public BigInteger B => BigInteger.Parse(line[idx++]);
    public BigInteger[] Bs => line.Skip(idx++).Select(BigInteger.Parse).ToArray();

    public void Write(params object[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
}

static class Extentions
{
    public static int Mod = 1000000007;
}

static class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Solve(new IO());
        Console.Out.Flush();
    }

    static void Solve(IO io)
    {
        io.R();
        var n = io.I;

        var dp1 = new int[4];
        var dp2 = new int[4];
        var dp3 = new int[4];

        dp1[0] = 1; dp2[0] = 0; dp3[0] = 0;
        dp1[1] = 0; dp2[1] = 1; dp3[1] = 0;
        dp1[2] = 1; dp2[2] = 1; dp3[2] = 1;

        if (n < 3)
        {
            io.Write(dp1[n - 1] + dp2[n - 1] + dp3[n - 1]);
            return;
        }

        for (var i = 3; i < n; i++)
        {
            dp1[3] = (dp2[2] + dp3[2]) % Mod;
            dp2[3] = (dp1[1] + dp3[1]) % Mod;
            dp3[3] = (dp1[0] + dp2[0]) % Mod;

            for (var j = 0; j < 3; j++)
            {
                dp1[j] = dp1[j + 1];
                dp2[j] = dp2[j + 1];
                dp3[j] = dp3[j + 1];
            }
        }

        io.Write((dp1[3] + dp2[3] + dp3[3]) % Mod);
    }
}
0