結果
問題 | No.3 ビットすごろく |
ユーザー |
![]() |
提出日時 | 2023-06-29 20:47:43 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 861 bytes |
コンパイル時間 | 16,267 ms |
コンパイル使用メモリ | 168,084 KB |
実行使用メモリ | 186,260 KB |
最終ジャッジ日時 | 2024-07-06 10:55:47 |
合計ジャッジ時間 | 18,803 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (81 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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); } } }