結果
問題 |
No.1006 Share an Integer
|
ユーザー |
![]() |
提出日時 | 2020-05-04 22:05:06 |
言語 | F# (F# 4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 859 bytes |
コンパイル時間 | 10,493 ms |
コンパイル使用メモリ | 195,556 KB |
実行使用メモリ | 81,920 KB |
最終ジャッジ日時 | 2024-06-25 00:51:38 |
合計ジャッジ時間 | 17,194 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 TLE * 1 -- * 10 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (308 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
// 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