結果

問題 No.300 平方数
ユーザー vain0vain0
提出日時 2015-11-14 01:08:54
言語 F#
(.NET 7)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 5,662 ms
コンパイル使用メモリ 163,896 KB
実行使用メモリ 33,292 KB
最終ジャッジ日時 2023-10-11 17:34:39
合計ジャッジ時間 11,906 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
24,960 KB
testcase_01 AC 84 ms
23,004 KB
testcase_02 AC 107 ms
29,168 KB
testcase_03 AC 84 ms
20,876 KB
testcase_04 AC 85 ms
22,976 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 85 ms
23,028 KB
testcase_08 AC 83 ms
22,908 KB
testcase_09 AC 84 ms
23,016 KB
testcase_10 AC 84 ms
25,048 KB
testcase_11 AC 84 ms
22,960 KB
testcase_12 AC 85 ms
25,060 KB
testcase_13 WA -
testcase_14 AC 87 ms
25,176 KB
testcase_15 AC 102 ms
29,152 KB
testcase_16 AC 99 ms
29,236 KB
testcase_17 AC 114 ms
29,156 KB
testcase_18 AC 88 ms
25,048 KB
testcase_19 AC 98 ms
29,168 KB
testcase_20 WA -
testcase_21 AC 114 ms
27,212 KB
testcase_22 AC 109 ms
29,156 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 108 ms
25,132 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 108 ms
29,272 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 95 ms
27,180 KB
testcase_34 AC 112 ms
27,132 KB
testcase_35 AC 103 ms
29,116 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 105 ms
31,068 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 103 ms
29,052 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 = 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) <= n do
        let (m', k) = split (! p) (! m)
        if k > 0 then yield (! p, k)
        p := (! p) + 1L
        m := m'
    // In case n is prime
    if (! m) = n then yield (n, 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 "%d" (solve x)

  //exit code
  0
0