結果

問題 No.1006 Share an Integer
コンテスト
ユーザー ikd
提出日時 2020-05-04 22:32:22
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
TLE  
実行時間 -
コード長 752 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,235 ms
コンパイル使用メモリ 212,208 KB
実行使用メモリ 186,584 KB
最終ジャッジ日時 2026-03-11 06:24:10
合計ジャッジ時間 41,904 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (183 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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

open System

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

    let d n =
        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
        res

    let f n = n - d n
    seq {
        for a = 1 to x - 1 do
            let b = x - a
            if (abs a - b) <= 320 then 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