結果

問題 No.889 素数!
ユーザー kya_ski
提出日時 2019-09-27 23:15:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 168,696 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 01:45:00
合計ジャッジ時間 2,957 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool is_prime(int _Num){
    if(_Num < 2)return false;
    if(_Num % 2 == 0){
        if(_Num == 2)return true;
        else return false;
    }
    bool prime = true;
    for(int i = 3; i <= sqrt(_Num); i += 2){
        if(_Num % i == 0){
            prime = false;
            break;
        }
    }
    return prime;
}

int main(){
    int N;
    cin >> N;
    string ans = to_string(N);
    int s = sqrt(N);
    if(is_prime(N))ans = "Sosu!";
    else if(N > 1 && s * s == N)ans = "Heihosu!";
    else if(N == 8 || N == 27 || N == 64)ans = "Ripposu!";
    else if(N == 6 || N == 28)ans = "Kanzensu!";
    
    cout << ans << endl;
    return 0;
}
0