結果

問題 No.3 ビットすごろく
ユーザー _matumo__matumo_
提出日時 2018-06-02 23:21:58
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,222 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 107,540 KB
実行使用メモリ 23,908 KB
最終ジャッジ日時 2023-09-14 01:00:38
合計ジャッジ時間 5,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
23,908 KB
testcase_01 AC 58 ms
21,636 KB
testcase_02 AC 62 ms
21,760 KB
testcase_03 AC 62 ms
23,720 KB
testcase_04 AC 58 ms
23,784 KB
testcase_05 AC 59 ms
21,692 KB
testcase_06 AC 59 ms
21,888 KB
testcase_07 AC 58 ms
21,800 KB
testcase_08 AC 60 ms
23,908 KB
testcase_09 AC 60 ms
21,764 KB
testcase_10 AC 61 ms
21,760 KB
testcase_11 AC 60 ms
21,904 KB
testcase_12 AC 60 ms
21,772 KB
testcase_13 AC 58 ms
21,692 KB
testcase_14 AC 61 ms
21,876 KB
testcase_15 AC 63 ms
21,996 KB
testcase_16 AC 62 ms
21,992 KB
testcase_17 AC 62 ms
23,828 KB
testcase_18 AC 58 ms
19,636 KB
testcase_19 AC 62 ms
21,832 KB
testcase_20 AC 59 ms
21,752 KB
testcase_21 WA -
testcase_22 AC 63 ms
23,808 KB
testcase_23 AC 62 ms
19,864 KB
testcase_24 AC 63 ms
21,704 KB
testcase_25 AC 63 ms
21,764 KB
testcase_26 AC 58 ms
21,792 KB
testcase_27 AC 58 ms
21,904 KB
testcase_28 AC 61 ms
21,776 KB
testcase_29 AC 59 ms
21,592 KB
testcase_30 AC 58 ms
21,764 KB
testcase_31 AC 57 ms
21,704 KB
testcase_32 AC 60 ms
21,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Linq;
using System.Text;

namespace YukiCoder
{
    class Program
    {
        static int[] bitCnt = new int[] { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
        static int[] pnStep;
        static int nMax;

        static int pnBitN(int ni)
        {
            return bitCnt[ni % 16]
                 + bitCnt[ni / 16 % 16]
                 + bitCnt[ni / 16 / 16 % 16]
                 + bitCnt[ni / 16 / 16 / 16 % 16];
        }

        static int zzz(int ns, int ni)
        {
            if (ni < 1 || ni > nMax) return nMax;
            if (ni == nMax) return 1;

            if (ns >= pnStep[ni]) return nMax;
            pnStep[ni] = ns;

            int n = pnBitN(ni);
            int na = zzz(ns + 1, ni + n);
            int nb = zzz(ns + 1, ni - n);
            return (na < nb ? na : nb) + 1;
        }

        static void Main(string[] args)
        {
            nMax = int.Parse(Console.ReadLine());
            pnStep = (new Int32[nMax+1]).Select(s => nMax).ToArray();
            int n = zzz(1, 1);
            if (n >= nMax && n != 1) n = -1;
            Console.WriteLine(n);
            Console.ReadLine();
        }
    }
}
0