結果

問題 No.36 素数が嫌い!
ユーザー shi-moshi-mo
提出日時 2016-10-26 22:09:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,582 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 15,580 KB
最終ジャッジ日時 2023-09-09 07:42:34
合計ジャッジ時間 8,597 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 308 ms
15,576 KB
testcase_01 AC 120 ms
15,524 KB
testcase_02 AC 95 ms
15,192 KB
testcase_03 AC 96 ms
15,268 KB
testcase_04 AC 94 ms
15,152 KB
testcase_05 AC 96 ms
15,320 KB
testcase_06 AC 101 ms
15,292 KB
testcase_07 AC 99 ms
15,468 KB
testcase_08 AC 97 ms
15,120 KB
testcase_09 AC 96 ms
15,100 KB
testcase_10 AC 94 ms
15,096 KB
testcase_11 AC 393 ms
15,324 KB
testcase_12 AC 1,013 ms
15,580 KB
testcase_13 AC 1,582 ms
15,408 KB
testcase_14 AC 100 ms
15,288 KB
testcase_15 AC 94 ms
15,292 KB
testcase_16 AC 94 ms
15,348 KB
testcase_17 AC 96 ms
15,176 KB
testcase_18 AC 94 ms
15,096 KB
testcase_19 AC 131 ms
15,516 KB
testcase_20 AC 141 ms
15,428 KB
testcase_21 AC 214 ms
15,396 KB
testcase_22 AC 109 ms
15,404 KB
testcase_23 AC 100 ms
15,404 KB
testcase_24 AC 307 ms
15,380 KB
testcase_25 AC 254 ms
15,556 KB
testcase_26 AC 418 ms
15,292 KB
testcase_27 AC 109 ms
15,288 KB
testcase_28 AC 412 ms
15,376 KB
testcase_29 AC 105 ms
15,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

n = gets.to_i

if 1 == n
  puts 'NO'
  exit 0
end

if Prime.prime?(n)
  puts 'NO'
  exit 0
end

c = 0
x = n
i = 1
while i <= x
  break if 3 <= c

  i += 1
  next if 0 != x % i

  while 0 == x % i
    c += 1
    x /= i
  end
  if Prime.prime?(x)
    c += 1
    break
  end
end
puts 3 <= c ? 'YES' : 'NO'
0