結果

問題 No.192 合成数
ユーザー taktak
提出日時 2019-02-15 01:25:39
言語 F#
(F# 4.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 3,494 ms
コンパイル使用メモリ 155,540 KB
実行使用メモリ 24,428 KB
最終ジャッジ日時 2023-10-11 13:50:10
合計ジャッジ時間 7,396 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
22,384 KB
testcase_01 AC 58 ms
22,424 KB
testcase_02 AC 58 ms
24,388 KB
testcase_03 AC 58 ms
22,392 KB
testcase_04 AC 57 ms
22,292 KB
testcase_05 AC 58 ms
24,284 KB
testcase_06 AC 58 ms
20,176 KB
testcase_07 AC 58 ms
22,328 KB
testcase_08 AC 59 ms
24,360 KB
testcase_09 AC 58 ms
20,176 KB
testcase_10 AC 58 ms
22,308 KB
testcase_11 AC 58 ms
22,504 KB
testcase_12 AC 58 ms
22,296 KB
testcase_13 AC 58 ms
24,340 KB
testcase_14 AC 58 ms
24,224 KB
testcase_15 AC 60 ms
22,496 KB
testcase_16 AC 58 ms
22,292 KB
testcase_17 AC 59 ms
24,336 KB
testcase_18 AC 58 ms
24,428 KB
testcase_19 AC 58 ms
22,176 KB
testcase_20 AC 58 ms
22,240 KB
testcase_21 AC 57 ms
22,172 KB
testcase_22 AC 58 ms
22,356 KB
testcase_23 AC 61 ms
24,380 KB
testcase_24 AC 58 ms
22,152 KB
testcase_25 AC 58 ms
22,300 KB
testcase_26 AC 59 ms
22,428 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let solve n =

  let inline primeFactor n =
      let zero = LanguagePrimitives.GenericZero
      let one  = LanguagePrimitives.GenericOne
      let two  = one + one
      let rec f num divisor acc =
          if divisor = num then
              divisor :: acc
          elif num % divisor = zero then
              f (num / divisor) divisor (divisor :: acc)
          else
              f num (divisor + one) acc
      f n two []
  
  [(max (n-100) 4) .. n+100]
  |> List.find (fun x -> (primeFactor x |> List.length) > 1)

let N = stdin.ReadLine() |> int

solve N
|> stdout.WriteLine
0