結果

問題 No.713 素数の和
ユーザー taktak
提出日時 2018-08-13 00:57:22
言語 F#
(F# 4.0)
結果
AC  
実行時間 715 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 7,808 ms
コンパイル使用メモリ 191,288 KB
実行使用メモリ 55,168 KB
最終ジャッジ日時 2023-10-24 16:26:00
合計ジャッジ時間 11,699 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 715 ms
55,128 KB
testcase_01 AC 62 ms
31,168 KB
testcase_02 AC 68 ms
31,384 KB
testcase_03 AC 214 ms
46,872 KB
testcase_04 AC 711 ms
55,168 KB
testcase_05 AC 93 ms
35,608 KB
testcase_06 AC 68 ms
31,368 KB
testcase_07 AC 68 ms
31,368 KB
testcase_08 AC 97 ms
36,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (237 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

let primLazy = 
    let odds = Seq.initInfinite (fun i -> 2 * i + 1)
    let rec f src =
        let (x, xs) = (Seq.head src, Seq.skip 1 src)
        seq {   
            yield x 
            for i in f xs do 
                if i % x <> 0 then yield i 
        }
    seq {   
        yield 2
        yield! f (Seq.skip 1 odds) 
    }

let N = stdin.ReadLine() |> int

primLazy
|> Seq.takeWhile(fun x -> x <= N)
|> Seq.sum
|> stdout.WriteLine
0