結果

問題 No.237 作図可能性
ユーザー Nobita GomuNobita Gomu
提出日時 2017-10-05 00:31:50
言語 F#
(F# 4.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 4,947 ms
コンパイル使用メモリ 162,024 KB
実行使用メモリ 25,764 KB
最終ジャッジ日時 2023-08-10 12:53:09
合計ジャッジ時間 9,507 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
23,596 KB
testcase_01 AC 101 ms
23,624 KB
testcase_02 AC 100 ms
25,612 KB
testcase_03 AC 101 ms
23,636 KB
testcase_04 AC 101 ms
25,588 KB
testcase_05 AC 100 ms
25,684 KB
testcase_06 AC 101 ms
25,672 KB
testcase_07 AC 101 ms
21,468 KB
testcase_08 AC 100 ms
25,604 KB
testcase_09 AC 103 ms
23,484 KB
testcase_10 AC 101 ms
23,588 KB
testcase_11 AC 102 ms
25,584 KB
testcase_12 AC 102 ms
25,652 KB
testcase_13 AC 102 ms
23,612 KB
testcase_14 AC 102 ms
23,692 KB
testcase_15 AC 102 ms
23,640 KB
testcase_16 AC 103 ms
23,604 KB
testcase_17 AC 102 ms
25,696 KB
testcase_18 AC 102 ms
23,564 KB
testcase_19 AC 101 ms
23,596 KB
testcase_20 AC 102 ms
25,688 KB
testcase_21 AC 103 ms
23,552 KB
testcase_22 AC 101 ms
23,656 KB
testcase_23 AC 103 ms
23,596 KB
testcase_24 AC 102 ms
21,664 KB
testcase_25 AC 101 ms
21,668 KB
testcase_26 AC 102 ms
25,764 KB
testcase_27 AC 101 ms
23,576 KB
testcase_28 AC 102 ms
23,636 KB
testcase_29 AC 100 ms
23,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let inline pow b e =
    let rec iter e acc =
        match e with
        | i when i = LanguagePrimitives.GenericZero -> acc
        | _ -> iter (e - LanguagePrimitives.GenericOne) (acc * b)
    iter e LanguagePrimitives.GenericOne

let rec product lst =
    match lst with
    | [] -> Seq.singleton []
    | x::xs -> Seq.collect (fun y -> product xs |> Seq.map (fun z -> y::z)) x

let count n =
    List.replicate 5 [0L;1L]
    |> product
    |> Seq.map (fun e ->
                    Seq.zip [3L;5L;17L;257L;65537L] e
                    |> Seq.map (fun e -> pow (fst e) (snd e))
                    |> Seq.reduce (*))
    |> Seq.filter (fun e -> e <> 1L && e <= 1000000000L)
    |> Seq.append [4L]
    |> Seq.map (fun i ->
                    Seq.initInfinite (fun e -> pow 2L e)
                    |> Seq.takeWhile (fun e -> i * e <= n)
                    |> Seq.length)
    |> Seq.sum

stdin.ReadLine () |> int64 |> count |> printfn "%d"
0