結果

問題 No.36 素数が嫌い!
ユーザー むらためむらため
提出日時 2017-08-13 10:19:54
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 743 bytes
コンパイル時間 2,988 ms
コンパイル使用メモリ 69,208 KB
実行使用メモリ 29,504 KB
最終ジャッジ日時 2023-09-12 14:27:16
合計ジャッジ時間 5,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
14,684 KB
testcase_01 AC 98 ms
27,356 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 42 ms
13,348 KB
testcase_12 AC 128 ms
29,504 KB
testcase_13 WA -
testcase_14 AC 75 ms
20,024 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 48 ms
13,952 KB
testcase_20 AC 119 ms
29,488 KB
testcase_21 AC 95 ms
27,196 KB
testcase_22 AC 95 ms
27,592 KB
testcase_23 AC 55 ms
14,924 KB
testcase_24 AC 62 ms
19,172 KB
testcase_25 AC 63 ms
19,076 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 50) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 57) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport]
/home/judge/data/code/Main.nim(1, 35) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,strscans,algorithm,math,future,macros
template get*():string = stdin.readLine()

proc getIsPrimes(n:int) :seq[bool] = # [0...n]
  result = newSeqWith(n+1,true)
  result[0] = false
  result[1] = false
  for i in 2..n.float.sqrt.int :
    if not result[i]: continue
    for j in countup(i*2,n,i):
      result[j] = false

proc getPrimes(n:int):seq[int] = # [2,3,5,...n]
  let isPrimes = getIsPrimes(n)
  result = @[]
  for i,p in isPrimes:
    if p : result &= i

proc getIsPrime(n:int) : bool = # O(N/2)
  let primes = getPrimes(n.float.sqrt.int + 1)
  for p in primes:
    if n mod p == 0 and n != p:
      return false
  return true

let N = get().parseInt()
if N == 1 or getIsPrime(N):
  echo "NO"
else:
  echo "YES"
0