結果

問題 No.3 ビットすごろく
ユーザー HimatsubushinHimatsubushin
提出日時 2019-01-21 10:13:13
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,532 bytes
コンパイル時間 3,828 ms
コンパイル使用メモリ 105,944 KB
実行使用メモリ 26,052 KB
最終ジャッジ日時 2023-10-13 17:14:23
合計ジャッジ時間 7,325 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
19,912 KB
testcase_01 AC 57 ms
23,852 KB
testcase_02 AC 58 ms
21,816 KB
testcase_03 AC 58 ms
21,908 KB
testcase_04 AC 57 ms
21,852 KB
testcase_05 AC 59 ms
21,940 KB
testcase_06 AC 58 ms
21,728 KB
testcase_07 AC 58 ms
21,916 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 60 ms
23,872 KB
testcase_13 AC 58 ms
21,896 KB
testcase_14 AC 59 ms
23,964 KB
testcase_15 AC 60 ms
21,984 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 58 ms
21,992 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 58 ms
21,808 KB
testcase_22 AC 59 ms
21,964 KB
testcase_23 AC 58 ms
21,992 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 56 ms
21,672 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 57 ms
21,876 KB
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

namespace No003_ビットすごろく
{
    class Program
    {
        static private int N;
        static private int[] Bit;
        static private bool[] Checker;

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());
            BitCheck();

            Console.WriteLine(Recursive(1, 1).ToString());
        }

        static void BitCheck()
        {
            int[] log2 = new int[N + 1];
            int temp, count;

            Bit = new int[N + 1];
            Checker = Enumerable.Repeat<bool>(false, N + 1).ToArray();

            log2[0] = 1;
            log2[1] = 1;

            Bit[0] = 0;
            Bit[1] = 1;

            temp = 1;
            count = 0;

            for (int i = 2; i <= N; i++)
            {
                log2[i] = (int)Math.Log((double)i, 2.0) + 1;
                if (log2[i] != temp)
                {
                    temp = log2[i];
                    count = 0;
                }
                Bit[i] = Bit[count] + 1;
                count++;
            }
        }

        static int Recursive(int level, int count)
        {

            if (Checker[level])
                return -1;
            else if (level == N)
                return count;

            Checker[level] = true;

            if (level + Bit[level] <= N)
                return Recursive(level + Bit[level], count + 1);
            else
                return Recursive(level - Bit[level], count + 1);
        }
    }
}
0