結果
問題 | No.3 ビットすごろく |
ユーザー | tak |
提出日時 | 2019-04-27 22:34:42 |
言語 | F# (F# 4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,013 bytes |
コンパイル時間 | 5,314 ms |
コンパイル使用メモリ | 159,012 KB |
実行使用メモリ | 26,420 KB |
最終ジャッジ日時 | 2023-08-19 23:07:14 |
合計ジャッジ時間 | 8,769 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
24,280 KB |
testcase_01 | AC | 57 ms
22,276 KB |
testcase_02 | AC | 58 ms
22,196 KB |
testcase_03 | AC | 58 ms
22,344 KB |
testcase_04 | WA | - |
testcase_05 | AC | 59 ms
24,344 KB |
testcase_06 | AC | 61 ms
24,232 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 58 ms
22,140 KB |
testcase_13 | AC | 58 ms
22,288 KB |
testcase_14 | AC | 59 ms
22,212 KB |
testcase_15 | AC | 58 ms
24,328 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 56 ms
22,288 KB |
testcase_22 | AC | 59 ms
22,468 KB |
testcase_23 | AC | 59 ms
22,416 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 56 ms
24,220 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
open System let bitCount x = let mutable x = x x <- x - ((x >>> 1) &&& 0x55555555) x <- (x &&& 0x33333333) + ((x >>> 2) &&& 0x33333333) x <- (x + (x >>> 4)) &&& 0x0f0f0f0f; x <- x + (x >>> 8); x <- x + (x >>> 16); x &&& 0x3f let isLeachable n = let dis = Array.zeroCreate (n + 1) dis.[1] <- 1 let rec visit x = let bit = bitCount x let f = x - bit let b = x + bit let f1 = f >= 1 && dis.[f] = 0 let f2 = b <= n && dis.[b] = 0 match (f1, f2) with | true, true -> dis.[f] <- dis.[x] + 1 dis.[b] <- dis.[x] + 1 visit f visit b | true, false -> dis.[f] <- dis.[x] + 1 visit f | false, true -> dis.[b] <- dis.[x] + 1 visit b | false, false -> () visit 1 dis.[n] let N = Console.ReadLine() |> int isLeachable N |> function | 0 -> -1 | x -> x |> Console.WriteLine