結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-06-10 16:37:57 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 106,960 KB |
実行使用メモリ | 27,976 KB |
最終ジャッジ日時 | 2024-07-06 15:22:33 |
合計ジャッジ時間 | 2,158 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 18 |
コンパイルメッセージ
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; 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; } } } }