結果
問題 |
No.316 もっと刺激的なFizzBuzzをください
|
ユーザー |
![]() |
提出日時 | 2016-08-27 16:12:37 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 341 ms / 1,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 6,550 ms |
コンパイル使用メモリ | 207,496 KB |
実行使用メモリ | 35,232 KB |
最終ジャッジ日時 | 2024-11-08 19:12:40 |
合計ジャッジ時間 | 20,291 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (231 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) /home/judge/data/code/Main.fs(13,5): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj] main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
open System let ri () = stdin.ReadLine() |> int let ria () = stdin.ReadLine().Split() |> Array.map int let rl () = stdin.ReadLine() |> int64 let rla () = stdin.ReadLine().Split() |> Array.map int64 let rec gcd a b = if a = 0L then b else gcd (b%a) a let lcm a b = a * b / (gcd a b) let N = rl () let [|a; b; c|] = rla () let mutable sum = N sum <- [a;b;c] |> Seq.sumBy (fun x -> N/x ) sum <- sum - ([(a,b);(b,c);(c,a)] |> Seq.sumBy (fun (x,y) -> N / (lcm x y) ) ) sum <- sum + (N / (Seq.reduce lcm [a;b;c])) sum |> printfn "%d"