結果

問題 No.889 素数!
ユーザー iqueue02
提出日時 2020-07-29 16:40:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 3,019 ms
コンパイル使用メモリ 195,668 KB
最終ジャッジ日時 2025-01-12 07:37:08
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef unsigned long long ll;
typedef long double ld;
typedef pair<int,int> P;
bool is_prime(long long n){
    for(long long i = 2; i*i <= n ; i++){
        if(n%i == 0) return false;
    }
    return n != 1 && n != 0;
}
vector<long long> divisor(long long n){
    vector<long long> res;
    for(long long i = 1; i*i <= n; i++){
        if(n%i==0){
            res.push_back(i);
            if(n/i != i)res.push_back(n/i);
        }
    }
    return res;
}

bool is_hei (int n){
  bool ok = false;
  for (int i = 2; i * i <= n; i++) {
    if (i * i == n) ok = true;
  }
  return ok;
}

bool is_rip (int n) {
  bool ok = false;
  for (int i = 2; i * i * i <= n; i++) {
    if (i * i * i == n) ok = true;
  }
  return ok;
}

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

  auto div = divisor(n);
  int cnt = 0;
  for (auto e : div) cnt += e;
  cnt -= n; 
  if (is_prime(n)) cout << "Sosu!" << endl;
  else if (is_hei(n)) cout << "Heihosu!" << endl;
  else if (is_rip(n)) cout << "Ripposu!" << endl;
  else if (cnt == n && n != 0) cout << "Kanzensu!" << endl;
  else cout << n << endl;
  return 0;
} 
0