結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() cin.tie(0), ios::sync_with_stdio(false)

template <typename T>
bool is_prime(T N)
{
    if (N < 2)
        return false;
    for (T i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

bool is_seq(int N)
{
    for (int i = 2; i * i <= N; i++)
    {
        if (i * i == N)
            return true;
    }
    return false;
}

bool is_cub(int N)
{

    for (int i = 2; i * i * i <= N; i++)
    {
        if (i * i * i == N)
            return true;
    }
    return false;
}

int N;

int main()
{
    cin >> N;
    bool flag = is_prime(N) || is_seq(N) || is_cub(N) || N == 6 || N == 28;
    if (is_prime(N))
        cout << "Sosu!\n";
    if (is_seq(N))
        cout << "Heihosu!\n";
    if (is_cub(N))
        cout << "Ripposu!\n";
    if (N == 6 || N == 28)
        cout << "Kanzensu!\n";
    if (!flag)
        cout << N << endl;
}
0