結果

問題 No.3 ビットすごろく
ユーザー abL8ZLsTbFabL8ZLsTbF
提出日時 2016-09-08 03:05:18
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 108,024 KB
実行使用メモリ 27,860 KB
最終ジャッジ日時 2024-04-27 17:56:15
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
23,516 KB
testcase_01 AC 22 ms
23,648 KB
testcase_02 AC 23 ms
25,668 KB
testcase_03 AC 23 ms
23,644 KB
testcase_04 AC 22 ms
24,008 KB
testcase_05 AC 23 ms
23,748 KB
testcase_06 AC 23 ms
23,476 KB
testcase_07 AC 24 ms
23,884 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 23 ms
23,732 KB
testcase_13 AC 23 ms
25,924 KB
testcase_14 AC 23 ms
21,808 KB
testcase_15 AC 23 ms
23,980 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 22 ms
23,640 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 22 ms
21,700 KB
testcase_22 AC 23 ms
23,852 KB
testcase_23 AC 24 ms
25,812 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 22 ms
23,516 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 23 ms
25,920 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;

public class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		var isUsed = new bool[N];
		isUsed[0] = true;
		for (int i = 1; i < N; i++)
		{
			isUsed[i] = false;
		}
		int ans = 1;
		int current = 1;
		while (current != N)
		{
			int move = 0;
			for (int temp = current; temp > 0; temp /= 2)
			{
				move += temp % 2;
			}
			if (current + move <= N && !isUsed[current + move - 1])
			{
				++ans;
				isUsed[(current += move) - 1] = true;
			}
			else if (current - move < 0 || isUsed[current - move - 1])
			{
				Console.WriteLine(-1);
				return;
			}
			else
			{
				++ans;
				isUsed[(current -= move) - 1] = true;
			}
		}
		Console.WriteLine(ans);
	}
}
0