結果

問題 No.3 ビットすごろく
ユーザー the10hoursthe10hours
提出日時 2015-06-10 16:37:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,394 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 98,004 KB
実行使用メモリ 22,848 KB
最終ジャッジ日時 2023-09-20 20:33:46
合計ジャッジ時間 4,878 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,744 KB
testcase_01 WA -
testcase_02 AC 54 ms
20,760 KB
testcase_03 AC 54 ms
20,676 KB
testcase_04 WA -
testcase_05 AC 55 ms
20,696 KB
testcase_06 AC 55 ms
22,744 KB
testcase_07 AC 53 ms
18,632 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 53 ms
20,772 KB
testcase_13 AC 54 ms
20,744 KB
testcase_14 AC 54 ms
20,624 KB
testcase_15 AC 53 ms
20,804 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 53 ms
20,760 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 54 ms
22,704 KB
testcase_22 AC 54 ms
22,788 KB
testcase_23 AC 53 ms
18,740 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 53 ms
20,740 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
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.Collections.Generic;
using System.Linq;
using System.Text;

namespace yukicoder
{
    class yc
    {
        static void Main()
        {
            //8192
            int N = int.Parse(Console.ReadLine());
            int cout = 1;
            int place = 1;
            int move = 0;
            int before = 0;
            bool end = false;

            while (!end)
            {
                for (int i = 8192; 0 < i; i /= 2)
                {
                    if ((place & i) != 0)
                    {
                        move++;
                    }
                }
                if (place == N)
                {
                    Console.WriteLine(cout);
                    break;
                }

                if (place + move > N)
                {
                    before = place;
                    place -= move;
                    cout++;
                }

                if (place + move <= N)
                {
                    place += move;
                    cout++;
                    if (place == before)
                    {
                        Console.WriteLine(-1);
                        break;
                    }
                    else
                    {
                        before = 0;
                    }
                }
                move = 0;
            }
        }
    }
}
0