結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2017-05-31 09:47:41 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 980 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 107,392 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-09-21 20:18:03 |
合計ジャッジ時間 | 2,586 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YukiCoder_Cs { class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); int move = 0; int cnt = 1; int i = 1; List<int> usedN = new List<int>(); while (i < N) { move = Convert.ToString(i, 2).ToCharArray().Where(c => c == '1').Count(); if (usedN.Contains(i)) { cnt = -1; break; } usedN.Add(i); if (i + move > N) { i -= move; } else { i += move; } ++cnt; } Console.WriteLine($"{cnt}"); } } }