結果
| 問題 | No.316 もっと刺激的なFizzBuzzをください |
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-08-27 16:17:44 |
| 言語 | F# (F# 4.0) |
| 結果 |
AC
|
| 実行時間 | 325 ms / 1,000 ms |
| コード長 | 726 bytes |
| 記録 | |
| コンパイル時間 | 11,105 ms |
| コンパイル使用メモリ | 209,844 KB |
| 実行使用メモリ | 34,840 KB |
| 最終ジャッジ日時 | 2024-11-08 19:15:25 |
| 合計ジャッジ時間 | 21,716 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (297 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) /home/judge/data/code/Main.fs(15,13): 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
type Sol() =
member this.Solve() =
let rec gcd s t = if s = 0L then t else gcd (t%s) s
let lcm s t = s * t / (gcd s t)
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"
let mySol = new Sol()
mySol.Solve()
kuuso1