結果

問題 No.3 ビットすごろく
ユーザー AdamantiteAdamantite
提出日時 2023-06-29 20:47:43
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 12,922 ms
コンパイル使用メモリ 145,080 KB
実行使用メモリ 166,208 KB
最終ジャッジ日時 2023-09-20 15:50:53
合計ジャッジ時間 15,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
28,644 KB
testcase_01 AC 50 ms
28,460 KB
testcase_02 AC 51 ms
28,496 KB
testcase_03 AC 50 ms
28,548 KB
testcase_04 AC 49 ms
28,472 KB
testcase_05 AC 49 ms
28,636 KB
testcase_06 AC 49 ms
28,624 KB
testcase_07 AC 50 ms
28,784 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 49 ms
28,860 KB
testcase_13 AC 50 ms
28,764 KB
testcase_14 AC 50 ms
30,852 KB
testcase_15 AC 50 ms
28,600 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 49 ms
28,724 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 49 ms
28,504 KB
testcase_22 AC 49 ms
28,488 KB
testcase_23 AC 50 ms
28,728 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 49 ms
28,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 50 ms
28,664 KB
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 128 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;
using System.Linq;

namespace No00003_BitSugoroku
{
    internal class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            bool[] map = new bool[n];
            int index = 1;
            int count = 0;
            while (true) {
                count++;
                if (index == n) {
                    break;
                }
                if (map[index]) {
                    count = -1;
                    break;
                }
                map[index] = true;
                int diff = Convert.ToString(index, 2).Count(x => x == '1');
                if (index + diff <= n) {
                    index += diff;
                } else {
                    index -= diff;
                }
            }
            Console.WriteLine(count);
        }
    }
}
0