結果

問題 No.889 素数!
ユーザー merom686merom686
提出日時 2019-09-20 21:36:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 74,216 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 16:46:56
合計ジャッジ時間 2,304 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;

    if (n <= 1) {
        cout << n << endl;
        exit(0);
    }

    int b = 0;
    for (int i = 2; i < n; i++) {
        if (n % i == 0) b = 1;
    }
    if (b == 0) {
        cout << "Sosu!" << endl;
        exit(0);
    }

    for (int i = 2; i < n; i++) {
        if (i * i == n) b = 0;
    }
    if (b == 0) {
        cout << "Heihosu!" << endl;
        exit(0);
    }

    for (int i = 2; i < n; i++) {
        if (i * i * i == n) b = 0;
    }
    if (b == 0) {
        cout << "Ripposu!" << endl;
        exit(0);
    }

    if (n == 6 || n == 28) {
        cout << "Kanzensu!" << endl;
        exit(0);
    }

    cout << n << endl;

    return 0;
}
0