結果

問題 No.14 最小公倍数ソート
ユーザー pocaristpocarist
提出日時 2015-10-06 13:28:19
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 5,648 ms
コンパイル使用メモリ 162,100 KB
実行使用メモリ 34,480 KB
最終ジャッジ日時 2023-09-27 07:34:36
合計ジャッジ時間 10,089 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
23,060 KB
testcase_01 AC 94 ms
23,168 KB
testcase_02 AC 93 ms
23,060 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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/37
open System
open System.Collections.Generic

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

let factors n =
    let i = ref 2
    let tmp = ref n
    seq {
        while !i * !i <= n do
            if !tmp % !i = 0 then
                tmp := !tmp / !i
                yield !i
            else
                incr i
        if !tmp <> 1 then yield !tmp
    }

[<EntryPoint>]
let main argv = 
    let N = Console.ReadLine().Trim() |> int
    let A = Console.ReadLine().Trim().Split([|' '|]) |> Array.map int
    let A' = Array.init (N-1) (fun i -> A.[i+1])
    A'
    |> Array.map (fun a -> factors a|>List.ofSeq, a)
    |> Array.sort
    |> Array.map snd
    |> List.ofArray
    |> fun a' -> A.[0] :: a'
    |> List.map string
    |> String.concat " "
    |> printfn "%s"
    0 // 整数の終了コードを返します
0