結果

問題 No.1006 Share an Integer
ユーザー ikdikd
提出日時 2020-05-04 22:05:06
言語 F#
(F# 4.0)
結果
TLE  
実行時間 -
コード長 859 bytes
コンパイル時間 4,268 ms
コンパイル使用メモリ 162,772 KB
実行使用メモリ 23,852 KB
最終ジャッジ日時 2023-09-07 06:27:55
合計ジャッジ時間 9,883 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
23,744 KB
testcase_01 AC 114 ms
23,616 KB
testcase_02 AC 113 ms
23,736 KB
testcase_03 AC 103 ms
23,488 KB
testcase_04 AC 112 ms
23,804 KB
testcase_05 AC 108 ms
23,380 KB
testcase_06 AC 112 ms
23,624 KB
testcase_07 AC 106 ms
23,556 KB
testcase_08 AC 111 ms
21,672 KB
testcase_09 AC 110 ms
23,852 KB
testcase_10 AC 111 ms
23,796 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
    let x = stdin.ReadLine() |> int

    let mutable memo = Array.create (x + 1) -1

    let d n =
        if memo.[n] < 0 then
            let mutable i = 1
            let mutable res = 0
            while i * i <= n do
                if n % i = 0 then
                    if i * i = n then res <- res + 1 else res <- res + 2
                i <- i + 1
            memo.[n] <- res
        memo.[n]

    let f n = n - d n
    seq {
        for a = 1 to x - 1 do
            let b = x - a
            yield (abs (f a - f b), a, b)
    }
    |> Seq.groupBy (fun (y, _, _) -> y)
    |> Seq.minBy (fun (y, s) -> y)
    |> snd
    |> Seq.map (fun (y, a, b) -> (a, b))
    |> Seq.sort
    |> Seq.iter (fun (a, b) -> printfn "%d %d" a b)
    0 // return an integer exit code
0