結果

問題 No.106 素数が嫌い!2
ユーザー guriceringuricerin
提出日時 2020-02-06 13:33:16
言語 F#
(.NET 7)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 4,115 bytes
コンパイル時間 7,036 ms
コンパイル使用メモリ 198,536 KB
実行使用メモリ 53,540 KB
最終ジャッジ日時 2023-10-25 22:31:39
合計ジャッジ時間 9,386 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
46,976 KB
testcase_01 AC 59 ms
33,072 KB
testcase_02 AC 58 ms
33,072 KB
testcase_03 AC 59 ms
33,072 KB
testcase_04 AC 100 ms
46,656 KB
testcase_05 AC 129 ms
49,744 KB
testcase_06 AC 124 ms
49,324 KB
testcase_07 AC 117 ms
48,460 KB
testcase_08 AC 65 ms
36,524 KB
testcase_09 AC 63 ms
36,084 KB
testcase_10 AC 117 ms
48,460 KB
testcase_11 AC 93 ms
42,120 KB
testcase_12 AC 141 ms
53,540 KB
testcase_13 AC 58 ms
33,068 KB
testcase_14 AC 57 ms
33,068 KB
testcase_15 AC 59 ms
33,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (212 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
/home/judge/data/code/Main.fs(48,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

//         /             ` 、       感謝するぜ  お前と出会えた
//        /          ノノ  ヽ
//       ,     ニニ彡'⌒    /`ヽ        これまでの  全てに
//       '   ニミ ニニ彡      〈rう├--ミ
//        { { ニミ } j j jノx'ィイく  }し{\   `丶、___/ニニニ
//       j_ニニミV ハレノ x<⌒ヽ  V ヘ  \    \ニニニニニニニ
//       {xミミー'ヾ(、ル( 厶tァァく⌒ヾ}  )ハ::::::.    \ニニニニニニ
//      彡ィ'">tァ} \(`ニ彡 ノ` /ト=く   ::::::i     \ニニニニニニ
//      (   V^`こ7  _, \``ヾヽ` ノ|`ヽ ヽ l:::::|       \ニニニニニ
//          ∧  { '  ` ノ^ヽ    { ノ     !:::::|   ___ノ^ヽニニニニニニ
//       /.::::\ゝヽ. _ノヽ``ヽ, -――- 、 /:::::/ /      ̄`ヽニニニニニ
//      /.::::::::::::::::>'"ノルハヽ`/ -―- 、⌒V::::::/.// j___ノ、  ヽニニニニニ
//   /ニニ、`ヽ`ヾヘ{ {、ムイ 、_(   >  \/ (__ ノニニニ     \ニニニニ
//  ,仁ニニニ\ヽヽヽ ∨   /ニニ>彡>--')__ ノ    `ヽニ     \ニニニ二
//  ニニニニニニヽ   /     {ニニ> ´ `¨¨´         ニ}      \>''"´
//  ニニニニニニニニ/     ∨ /               }八
//  ニニニニニニニ./        }ニ{                ノニヽ     ノ
//  ニニニニニニニ/       }ニハ               /⌒ヽヽヽ ___彡
//  ニニニニニニニ!        ノニニヽ、            /     ` ー=彡'ニニニニニ
//  ニニニニニニニ}          ⌒`丶、     /⌒ヽ  ノ     ノ_____
//   / ̄ ̄ ̄`ヽ/ヽ、 _彡ヘ{ {        > 、 /     /  ̄ ̄ ̄
//      ) 、    /   ヾ、    ヽ ヽ      (    `{    /
//  // ⌒ヽ  /    〃 トミ  ___ >--‐=、   ヽ _ノ
//   {       /    //     /         \__ノ

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let [| n; k |] = reada int
    let mp = Array.zeroCreate (int 1e6 * 2 + 1) // 素因数の数
    for p in 2 .. n do
        if mp.[p] > 0 then
            ()
        else
            mp.[p] <- 1
            let rec loop q =
                let pq = int64 p * int64 q
                if pq > int64 n then
                    ()
                else
                    mp.[p * q] <- mp.[p * q] + mp.[p]
                    loop (q + 1)
            loop 2

    mp.[2..n]
    |> Array.filter (fun x -> x >= k)
    |> Array.length
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()
0