結果

問題 No.300 平方数
ユーザー vain0vain0
提出日時 2015-11-14 01:05:03
言語 F#
(.NET 7)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 6,211 ms
コンパイル使用メモリ 164,336 KB
実行使用メモリ 31,352 KB
最終ジャッジ日時 2023-10-11 17:34:23
合計ジャッジ時間 12,292 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
23,168 KB
testcase_01 AC 88 ms
25,048 KB
testcase_02 AC 111 ms
31,088 KB
testcase_03 AC 85 ms
23,040 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 87 ms
23,192 KB
testcase_08 AC 85 ms
22,928 KB
testcase_09 AC 86 ms
24,972 KB
testcase_10 AC 86 ms
22,924 KB
testcase_11 AC 86 ms
24,964 KB
testcase_12 AC 87 ms
23,008 KB
testcase_13 WA -
testcase_14 AC 89 ms
25,056 KB
testcase_15 AC 102 ms
29,064 KB
testcase_16 AC 102 ms
31,036 KB
testcase_17 AC 118 ms
29,208 KB
testcase_18 AC 90 ms
24,964 KB
testcase_19 AC 100 ms
29,228 KB
testcase_20 WA -
testcase_21 AC 119 ms
31,112 KB
testcase_22 AC 115 ms
29,156 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 109 ms
27,036 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 106 ms
29,096 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 m = ref n
    let p = ref 2L
    while (! p) * (! p) <= n do
      let (m', k) = split (! p) (! m)
      if k > 0L then yield (! p, k)
      p := (! p) + 1L
      m := m'
      ]

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

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

  //exit code
  0
0