結果
問題 | No.3 ビットすごろく |
ユーザー | AreTrash |
提出日時 | 2016-04-09 03:50:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,028 bytes |
コンパイル時間 | 822 ms |
コンパイル使用メモリ | 110,836 KB |
実行使用メモリ | 26,084 KB |
最終ジャッジ日時 | 2024-04-14 23:31:25 |
合計ジャッジ時間 | 3,998 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
23,784 KB |
testcase_01 | AC | 22 ms
23,680 KB |
testcase_02 | AC | 22 ms
23,924 KB |
testcase_03 | AC | 30 ms
23,920 KB |
testcase_04 | AC | 23 ms
23,944 KB |
testcase_05 | AC | 56 ms
25,868 KB |
testcase_06 | AC | 31 ms
23,660 KB |
testcase_07 | AC | 25 ms
23,792 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 58 ms
24,112 KB |
testcase_13 | AC | 29 ms
23,920 KB |
testcase_14 | AC | 105 ms
25,768 KB |
testcase_15 | AC | 147 ms
23,924 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 30 ms
25,644 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 24 ms
25,572 KB |
testcase_22 | AC | 104 ms
26,084 KB |
testcase_23 | AC | 158 ms
23,920 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 22 ms
23,668 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 25 ms
23,796 KB |
testcase_32 | WA | - |
コンパイルメッセージ
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; namespace No3_1{ public class Program{ private static List<int> stack = new List<int>(); public static void Main(string[] args){ var result = Function(int.Parse(Console.ReadLine()), 1, 1); if(result == int.MaxValue) result = -1; Console.WriteLine(result); } public static int Function(int input, int place, int cnt){ if(place == input) return cnt; if(cnt >= input || stack.Contains(place) || place < 1 || input < place) return int.MaxValue; stack.Add(place); var result = Math.Min(Function(input, place + BitOne(place), cnt + 1), Function(input, place - BitOne(place), cnt + 1)); return result; } public static int BitOne(int num){ var result = 0; while(true){ if(num % 2 == 1) result++; if((num /= 2) == 0) break; } return result; } } }