結果

問題 No.3 ビットすごろく
ユーザー regeregeregerege
提出日時 2015-10-17 07:56:45
言語 F#
(F# 4.0)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 957 bytes
コンパイル時間 3,529 ms
コンパイル使用メモリ 163,420 KB
実行使用メモリ 25,028 KB
最終ジャッジ日時 2023-09-13 23:25:59
合計ジャッジ時間 7,795 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
23,008 KB
testcase_01 AC 86 ms
24,936 KB
testcase_02 AC 85 ms
22,860 KB
testcase_03 AC 86 ms
22,988 KB
testcase_04 AC 86 ms
23,152 KB
testcase_05 AC 88 ms
25,012 KB
testcase_06 AC 86 ms
23,004 KB
testcase_07 AC 85 ms
22,908 KB
testcase_08 AC 87 ms
22,912 KB
testcase_09 AC 86 ms
22,984 KB
testcase_10 AC 87 ms
22,928 KB
testcase_11 AC 87 ms
23,000 KB
testcase_12 AC 86 ms
22,916 KB
testcase_13 AC 85 ms
22,920 KB
testcase_14 AC 87 ms
22,876 KB
testcase_15 AC 88 ms
23,040 KB
testcase_16 AC 87 ms
22,936 KB
testcase_17 AC 87 ms
22,956 KB
testcase_18 AC 87 ms
22,888 KB
testcase_19 AC 87 ms
23,020 KB
testcase_20 AC 86 ms
24,992 KB
testcase_21 AC 85 ms
23,012 KB
testcase_22 AC 87 ms
22,944 KB
testcase_23 AC 88 ms
22,992 KB
testcase_24 AC 88 ms
24,960 KB
testcase_25 AC 87 ms
24,984 KB
testcase_26 AC 85 ms
24,964 KB
testcase_27 AC 86 ms
22,948 KB
testcase_28 AC 87 ms
24,948 KB
testcase_29 AC 87 ms
22,980 KB
testcase_30 AC 85 ms
22,952 KB
testcase_31 AC 86 ms
22,924 KB
testcase_32 AC 88 ms
25,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System.Collections
let ``No.3 ビットすごろく`` () =
    let bitcount (bit:int) =
        let a = (bit &&& 0x55555555) + (bit >>> 1 &&& 0x55555555) in
        let b = (a &&& 0x33333333) + (a >>> 2 &&& 0x33333333) in
        let c = (b &&& 0x0F0F0F0F) + (b >>> 4 &&& 0x0F0F0F0F) in
        let d = (c &&& 0x00FF00FF) + (c >>> 8 &&& 0x00FF00FF) in
        (d &&& 0x0000FFFF) + (d >>> 16 &&& 0x0000FFFF)
    let N = int <| stdin.ReadLine()
    let aa = [| yield 0; yield 1; for i in 2..N -> -1 |]
    let f2 f p p2 l =
        if f p2 && aa.[p2] = -1 then
            aa.[p2] <- aa.[p] + 1
            l@[p2]
        else l
    let rec f = function
        | p::ps ->
            if p = N then aa.[N]
            else
                let bc = bitcount p
                let ps = f2 ((<=)1) p (p-bc) ps
                let ps = f2 ((>=)N) p (p+bc) ps
                f ps
        | _ -> -1
    printfn "%d" <| f [1]
``No.3 ビットすごろく`` ()
0