結果

問題 No.36 素数が嫌い!
ユーザー toshiro_yanagi
提出日時 2019-01-05 01:07:30
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 3,522 ms
コンパイル使用メモリ 70,016 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 06:21:29
合計ジャッジ時間 5,871 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, tables


proc isUsableNum(a: int): bool =
  var
    x = a
    dic = initCountTable[int]()
    i = 2

  while i * i <= a:
    while x mod i == 0:
      inc dic, i
      x = x div i
    inc i

  if x != 1: inc dic, x

  if dic.len >= 3: return true
  for k, v in dic:
    if v >= 2: return true


proc main: void =
  let n = parseInt readLine stdin
  ["NO", "YES"][n.isUsableNum.int].echo


when isMainModule:
  main()
0