結果

問題 No.889 素数!
ユーザー yuruhiya
提出日時 2019-09-26 20:07:47
言語 Ruby
(3.4.1)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-09-23 08:08:09
合計ジャッジ時間 7,721 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def isSosu(n)
    if n==2
        return true
    elsif n<2 || n%2==0
        return false
    end
    for i in 3...n
        if n%i==0
            return false
        end
    end
    return true
end

def isHeiho(n)
    sq=Math.sqrt(n).to_i
    if sq*sq==n && 2<=n
        return true
    else
        return false
    end
end

def isRippou(n)
    if n==8||n==27
        return true
    else
        return false
    end
end

def isKanzen(n)
    if n==6||n==28
        return true
    else
        return false
    end
end


n=gets.to_i
if isSosu(n)
    print('Sosu!')
elsif isHeiho(n)
    print('Heihosu!')
elsif isRippou(n)
    print('Ripposu!')
elsif isKanzen(n)
    print('Kanzensu!')
else
    print(n)
end
0