結果

問題 No.300 平方数
ユーザー vain0vain0
提出日時 2015-11-14 01:19:00
言語 F#
(.NET 7)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 676 bytes
コンパイル時間 3,480 ms
コンパイル使用メモリ 163,884 KB
実行使用メモリ 31,120 KB
最終ジャッジ日時 2023-10-11 17:35:09
合計ジャッジ時間 9,264 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
22,960 KB
testcase_01 AC 85 ms
24,936 KB
testcase_02 AC 85 ms
25,020 KB
testcase_03 AC 84 ms
23,080 KB
testcase_04 AC 85 ms
22,976 KB
testcase_05 AC 85 ms
23,020 KB
testcase_06 AC 85 ms
25,120 KB
testcase_07 AC 84 ms
22,852 KB
testcase_08 AC 85 ms
25,068 KB
testcase_09 AC 86 ms
22,928 KB
testcase_10 AC 85 ms
22,956 KB
testcase_11 AC 85 ms
22,964 KB
testcase_12 AC 85 ms
22,840 KB
testcase_13 AC 117 ms
29,188 KB
testcase_14 AC 85 ms
25,048 KB
testcase_15 AC 85 ms
22,948 KB
testcase_16 AC 85 ms
24,952 KB
testcase_17 AC 84 ms
23,016 KB
testcase_18 AC 85 ms
22,908 KB
testcase_19 AC 85 ms
22,972 KB
testcase_20 AC 87 ms
22,948 KB
testcase_21 AC 87 ms
22,968 KB
testcase_22 AC 85 ms
22,880 KB
testcase_23 AC 88 ms
24,892 KB
testcase_24 AC 91 ms
27,164 KB
testcase_25 AC 112 ms
29,028 KB
testcase_26 AC 93 ms
29,124 KB
testcase_27 AC 91 ms
25,160 KB
testcase_28 AC 110 ms
29,076 KB
testcase_29 AC 104 ms
27,060 KB
testcase_30 AC 86 ms
22,976 KB
testcase_31 AC 87 ms
24,892 KB
testcase_32 AC 86 ms
23,008 KB
testcase_33 AC 95 ms
29,176 KB
testcase_34 AC 111 ms
29,056 KB
testcase_35 AC 103 ms
31,120 KB
testcase_36 AC 92 ms
29,180 KB
testcase_37 AC 92 ms
27,212 KB
testcase_38 AC 84 ms
23,028 KB
testcase_39 AC 86 ms
22,984 KB
testcase_40 AC 86 ms
25,016 KB
testcase_41 AC 90 ms
27,200 KB
testcase_42 AC 84 ms
22,916 KB
testcase_43 AC 85 ms
22,964 KB
testcase_44 AC 85 ms
23,080 KB
testcase_45 AC 84 ms
23,036 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = 0
      while n % p = 0L do
          k <- k + 1
          n <- n / p
      (n, k)

  [ let m = ref n
    let p = ref 2L
    while (! p) * (! p) <= (! m) do
        let (m', k) = split (! p) (! m)
        if k > 0 then yield (! p, k)
        p := (! p) + 1L
        m := m'
    if (! m) <> 0L then yield (! m, 1)
    ]

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

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

  //exit code
  0
0