結果
問題 | No.36 素数が嫌い! |
ユーザー | むらため |
提出日時 | 2017-08-13 10:33:01 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 114 ms / 5,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 3,114 ms |
コンパイル使用メモリ | 69,248 KB |
実行使用メモリ | 29,600 KB |
最終ジャッジ日時 | 2023-09-12 14:27:29 |
合計ジャッジ時間 | 5,765 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
14,756 KB |
testcase_01 | AC | 81 ms
27,388 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,384 KB |
testcase_11 | AC | 37 ms
13,388 KB |
testcase_12 | AC | 109 ms
29,432 KB |
testcase_13 | AC | 114 ms
29,432 KB |
testcase_14 | AC | 61 ms
20,208 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,376 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 38 ms
14,012 KB |
testcase_20 | AC | 101 ms
29,600 KB |
testcase_21 | AC | 78 ms
27,236 KB |
testcase_22 | AC | 80 ms
27,488 KB |
testcase_23 | AC | 46 ms
14,760 KB |
testcase_24 | AC | 53 ms
19,192 KB |
testcase_25 | AC | 52 ms
19,096 KB |
testcase_26 | AC | 63 ms
19,912 KB |
testcase_27 | AC | 95 ms
28,128 KB |
testcase_28 | AC | 63 ms
19,824 KB |
testcase_29 | AC | 106 ms
29,124 KB |
コンパイルメッセージ
/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]
ソースコード
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 let N = get().parseInt() primes = getPrimes(N.float.sqrt.int + 1) if N == 1 : echo "NO" quit() for p1 in primes: if N mod p1 != 0: continue let factor = N div p1 for p2 in primes: if factor mod p2 != 0: continue if factor == p2 : echo "NO" else: echo "YES" quit() echo "NO" quit() echo "NO"