結果

問題 No.889 素数!
ユーザー 37zigen
提出日時 2019-09-20 23:05:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 74,132 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 19:33:45
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

bool f0(int N) {
  if (N<2) return false;
  for (int i=2;i<N;++i) if (N%i==0) return false;
  return true;
}

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

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

bool f3(int N) {
  if (N==0) return false;
  long long sum=0;
  for (int i=1;i<N;++i) if (N%i==0) sum+=i;
  return sum==N;
}

int main() {
  int N;
  std::cin>>N;
  if (f0(N)) {
    std::cout<<"Sosu!"<<std::endl;
  } else if (f1(N)) {
    std::cout<<"Heihosu!"<<std::endl;
  } else if (f2(N)) {
    std::cout<<"Ripposu!"<<std::endl;
  } else if (f3(N)) {
    std::cout<<"Kanzensu!"<<std::endl;
  } else {
    std::cout<<N<<std::endl;
  }
  return 0;
}
0