結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kuuso1
提出日時 2016-08-27 17:17:46
言語 F#
(F# 4.0)
結果
AC  
実行時間 344 ms / 1,000 ms
コード長 772 bytes
コンパイル時間 6,858 ms
コンパイル使用メモリ 199,944 KB
実行使用メモリ 35,068 KB
最終ジャッジ日時 2024-11-08 19:30:35
合計ジャッジ時間 21,101 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (226 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(18,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/

ソースコード

diff #

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 = 
            match s with
            | 0L -> t
            | _  -> 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()
0