結果

問題 No.2 素因数ゲーム
ユーザー pocaristpocarist
提出日時 2015-08-31 14:43:45
言語 F#
(.NET 7)
結果
AC  
実行時間 487 ms / 5,000 ms
コード長 966 bytes
コンパイル時間 4,888 ms
コンパイル使用メモリ 165,972 KB
実行使用メモリ 25,112 KB
最終ジャッジ日時 2023-08-27 04:07:50
合計ジャッジ時間 9,951 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
24,888 KB
testcase_01 AC 85 ms
22,916 KB
testcase_02 AC 86 ms
23,032 KB
testcase_03 AC 87 ms
25,112 KB
testcase_04 AC 84 ms
22,920 KB
testcase_05 AC 85 ms
22,932 KB
testcase_06 AC 85 ms
24,940 KB
testcase_07 AC 86 ms
22,880 KB
testcase_08 AC 97 ms
22,924 KB
testcase_09 AC 86 ms
24,964 KB
testcase_10 AC 85 ms
23,040 KB
testcase_11 AC 85 ms
25,032 KB
testcase_12 AC 86 ms
23,032 KB
testcase_13 AC 86 ms
22,928 KB
testcase_14 AC 87 ms
23,072 KB
testcase_15 AC 88 ms
22,848 KB
testcase_16 AC 87 ms
22,904 KB
testcase_17 AC 89 ms
22,980 KB
testcase_18 AC 86 ms
20,936 KB
testcase_19 AC 307 ms
23,052 KB
testcase_20 AC 233 ms
22,788 KB
testcase_21 AC 487 ms
22,920 KB
testcase_22 AC 97 ms
24,972 KB
testcase_23 AC 86 ms
22,864 KB
testcase_24 AC 85 ms
22,848 KB
testcase_25 AC 96 ms
25,000 KB
testcase_26 AC 87 ms
22,868 KB
testcase_27 AC 85 ms
23,060 KB
testcase_28 AC 85 ms
20,888 KB
testcase_29 AC 87 ms
22,932 KB
testcase_30 AC 85 ms
24,968 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

// http://yukicoder.me/problems/18
open System

let dprintfn fmt = Printf.kprintf Diagnostics.Debug.WriteLine fmt

module Prime =
    let decomposit n =
        let ans = ref []
        let a = ref 2
        let tmp = ref n
        while !tmp >= !a do
            if !tmp % !a = 0 then
                ans := !a :: !ans
                tmp := !tmp / !a
            else
                incr a
        if !tmp = 1 then !ans
        else !tmp :: !ans

let solve N =
    Prime.decomposit N
//    |> fun a -> dprintfn "%A" a; a
    |> Seq.fold (fun s t -> 
                    match Map.tryFind t s with
                    | Some v -> Map.add t (v+1) s
                    | _ -> Map.add t 1 s
                ) Map.empty
//    |> fun a -> dprintfn "%A" a; a
    |> Map.fold (fun s _ v -> v ^^^ s) 0
    |> fun m -> 
        if m <> 0 then "Alice" else "Bob"

[<EntryPoint>]
let main argv = 
    let N = Console.ReadLine() |> int
    solve N
    |> printfn "%s" 
    0
0