結果
| 問題 |
No.889 素数!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-21 19:41:46 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 453 bytes |
| コンパイル時間 | 118 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-09-19 03:04:08 |
| 合計ジャッジ時間 | 9,062 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 58 WA * 2 RE * 1 |
コンパイルメッセージ
Syntax OK
ソースコード
require 'prime'
n = gets.chomp.to_i
sum =0
case n
when 4,9,16
puts "Heihosu!"
exit
when 8,27
puts "Ripposu!"
exit
end
def divisors(n)
n.prime_division.inject([1]) do |ary, (p, e)|
(0..e).map{ |e1| p ** e1
}.product(ary).map{ |a, b| a * b }
end.sort
end
eval = divisors(n)
if eval.length ==2
puts "Sosu!"
else
eval.each do |elem|
sum+=elem if elem < n
end
if sum == n
puts "Kanzensu!"
else
puts n
end
end