結果

問題 No.889 素数!
ユーザー CroweaCrowea
提出日時 2020-04-29 00:47:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,738 bytes
コンパイル時間 3,312 ms
コンパイル使用メモリ 205,352 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 11:12:41
合計ジャッジ時間 4,325 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,384 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 2 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"              // only gcc
using namespace std;                  // std::cout, std::endl

#pragma region TEMPLATE
constexpr auto INF = 1000000000000;   //10^12;;
constexpr auto MOD = 1000000007;      //10^9+7;;
constexpr auto EPS = 1e-9;
constexpr auto PI  = 3.141592653589793238462643383279;
#define endl '\n';                    // std::endl => '\n'
#define nl  cout << endl;
#define ALL(v) v.begin(), v.end() 
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(v) sort(ALL(v)) 
#define RSORT(v) sort(RALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SZ(x) ((int)(x).size())
#define FOR(i,j,k)  for (int i=j; i<k; i++)
#define RFOR(i,j,k) for (int i=j; i>=k; i--)
#define REP(i, j)   FOR(i, 0, j)
#define RREP(i, j) RFOR(i, j, 0)
#define FOREACH(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define YES(p) cout << (p ? "YES":"NO") << endl;
#define Yes(p) cout << (p ? "Yes":"No") << endl;
template<class T = int>T in(){T x; cin >> x; return x; }   // read
template<class T> void out(T value){ cout << value << endl; }// write
template<class T> bool chmax(T& a,const T& b){ if (a < b){ a = b; return 1; } return 0; } // change max
template<class T> bool chmin(T& a,const T& b){ if (b < a){ a = b; return 1; } return 0; } // change min

using  VI = vector<int>;
using  ll = long long;
using VLL = vector<ll>;
#pragma endregion

bool isPrime(ll n) {
    if (n <= 1)     return false;
    else if (n == 2) return true;

    if (n % 2 == 0) return false;
    for (ll i = 3; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

bool isSquare(ll num) {
    ll rt = ll(sqrt(double(num)));
    return rt * rt == num;
}
bool isCubic(ll num) {
    ll rt = ll(cbrt(double(num)));
    return rt * rt * rt == num;
}
vector<int64_t> divisor(int64_t n) {
    vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}
bool isPerfect(ll num) {    
    ll sum{ 0 };
    auto divs = divisor(num);
    for (auto v : divs) {
        if (v != num) {
            sum += v;
        }
    }
    return sum == num;
}

signed main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false); 
    cout << fixed << setprecision(10);
    
    ll n = in<ll>();
    if (n == 0) {
        out(0);
        return 0;
    }

    if (isPrime(n)) {
        out("Sosu!");
    }
    else if (n >= 2 and isSquare(n)) {
        out("Heihosu!");
    }
    else if(n >= 2 and isCubic(n)) {
        out("Ripposu!");
    }
    else if (isPerfect(n)) {
        out("Kanzensu!");
    }
    else {
        out(n);
    }

    return 0;
}
0