結果

問題 No.889 素数!
ユーザー ManjushriMitra
提出日時 2024-07-27 13:15:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 167,664 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-27 13:15:32
合計ジャッジ時間 4,225 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<n; ++i)
#define repl(i,m,n) for(ll i=m; i<n; ++i)

bool is_prime(int x){
    for(int i=2; i*i<=x; ++i){
        if(x % i == 0) return false;
    }
    return true;
}

bool is_square(int x){
    for(int i=1; i*i<= x; ++i){
        if(i*i == x) return true;
    }
    return false;
}

bool is_cube(int x){
    for(int i=1; i*i*i<=x; ++i){
        if(i*i*i == x) return true;
    }
    return false;
}

int main(){
    int N;
    cin >> N;

    if(N == 0 || N == 1){
        cout << N << endl;
    }else if(N == 6 || N == 28){
        cout << "Kanzensu!" << endl;
    }else if(is_prime(N)){
        cout << "Sosu!" << endl;
    }else if(is_square(N)){
        cout << "Heihosu!" << endl;
    }else if(is_cube(N)){
        cout << "Ripposu!" << endl;
    }else{
        cout << N << endl;
    }
    
    return 0;
}
0