結果

問題 No.300 平方数
ユーザー vain0vain0
提出日時 2015-11-14 00:49:48
言語 F#
(.NET 7)
結果
TLE  
実行時間 -
コード長 650 bytes
コンパイル時間 4,631 ms
コンパイル使用メモリ 160,048 KB
実行使用メモリ 33,312 KB
最終ジャッジ日時 2023-10-11 17:33:57
合計ジャッジ時間 9,717 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
30,320 KB
testcase_01 AC 97 ms
23,364 KB
testcase_02 AC 98 ms
25,460 KB
testcase_03 AC 94 ms
23,456 KB
testcase_04 AC 96 ms
23,600 KB
testcase_05 AC 97 ms
25,408 KB
testcase_06 AC 96 ms
23,328 KB
testcase_07 AC 98 ms
23,476 KB
testcase_08 AC 95 ms
23,532 KB
testcase_09 AC 96 ms
21,376 KB
testcase_10 AC 96 ms
23,416 KB
testcase_11 AC 97 ms
23,340 KB
testcase_12 AC 96 ms
23,428 KB
testcase_13 AC 187 ms
27,408 KB
testcase_14 AC 99 ms
23,320 KB
testcase_15 AC 98 ms
23,440 KB
testcase_16 AC 97 ms
25,440 KB
testcase_17 AC 95 ms
25,408 KB
testcase_18 AC 96 ms
21,272 KB
testcase_19 AC 96 ms
25,376 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System

let factorize n =
  let split p n =
      let mutable n = n
      let mutable k = 0L
      while n % p = 0L do
          k <- k + 1L
          n <- n / p
      (n, k)
  let f (p, n) =
    if p <= n then
        let (m, k) = split p n
        let elem = if k > 0L then Some (p, k) else None
        Some (elem, (p + 1L, m))
    else None

  Seq.unfold f (2L, n) |> Seq.choose id |> Map.ofSeq

let solve n =
  factorize n
  |> Map.toSeq
  |> Seq.choose (fun (k, v) -> if v % 2L <> 0L then Some k else None)
  |> Seq.fold (*) 1L

[<EntryPoint>]
let main _ =
  let x = Console.ReadLine() |> int64
  printfn "%d" (solve x)

  //exit code
  0
0