結果
問題 | No.3 ビットすごろく |
ユーザー | mban |
提出日時 | 2016-10-31 14:02:41 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 64 ms / 5,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 2,248 ms |
コンパイル使用メモリ | 106,284 KB |
実行使用メモリ | 23,772 KB |
最終ジャッジ日時 | 2023-09-14 00:11:19 |
合計ジャッジ時間 | 5,598 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
21,576 KB |
testcase_01 | AC | 60 ms
23,668 KB |
testcase_02 | AC | 59 ms
21,600 KB |
testcase_03 | AC | 61 ms
21,548 KB |
testcase_04 | AC | 60 ms
23,636 KB |
testcase_05 | AC | 61 ms
21,500 KB |
testcase_06 | AC | 61 ms
21,728 KB |
testcase_07 | AC | 61 ms
19,540 KB |
testcase_08 | AC | 62 ms
21,684 KB |
testcase_09 | AC | 61 ms
19,596 KB |
testcase_10 | AC | 62 ms
23,772 KB |
testcase_11 | AC | 62 ms
21,552 KB |
testcase_12 | AC | 62 ms
21,592 KB |
testcase_13 | AC | 61 ms
21,628 KB |
testcase_14 | AC | 63 ms
23,600 KB |
testcase_15 | AC | 64 ms
23,648 KB |
testcase_16 | AC | 64 ms
23,592 KB |
testcase_17 | AC | 62 ms
21,648 KB |
testcase_18 | AC | 60 ms
21,636 KB |
testcase_19 | AC | 63 ms
21,736 KB |
testcase_20 | AC | 60 ms
21,624 KB |
testcase_21 | AC | 59 ms
23,680 KB |
testcase_22 | AC | 63 ms
23,616 KB |
testcase_23 | AC | 64 ms
21,780 KB |
testcase_24 | AC | 62 ms
21,592 KB |
testcase_25 | AC | 63 ms
21,548 KB |
testcase_26 | AC | 59 ms
19,504 KB |
testcase_27 | AC | 60 ms
21,592 KB |
testcase_28 | AC | 63 ms
21,568 KB |
testcase_29 | AC | 61 ms
19,532 KB |
testcase_30 | AC | 60 ms
21,556 KB |
testcase_31 | AC | 61 ms
23,612 KB |
testcase_32 | AC | 62 ms
23,592 KB |
コンパイルメッセージ
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; class Magatro { static void Main() { int N = int.Parse(Console.ReadLine()); int[] w = (new int[N + 1]).Select(s=>-1).ToArray(); w[1] = 1; Queue<int> q = new Queue<int>(); q.Enqueue(1); while (q.Count > 0) { int e = q.Dequeue(); if (e + bit(e) <= N&& w[e + bit(e)]==-1) { w[e + bit(e)] = w[e] + 1; q.Enqueue(e + bit(e)); } if (e - bit(e) >= 1&& w[e - bit(e)]==-1) { w[e - bit(e)] = w[e] + 1; q.Enqueue(e - bit(e)); } } Console.WriteLine(w[N]); } static int bit(int n) { if (n == 0) { return 0; } return bit(n / 2) + n % 2; } }