結果
| 問題 |
No.889 素数!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-24 21:58:36 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 872 bytes |
| コンパイル時間 | 990 ms |
| コンパイル使用メモリ | 137,512 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 18:47:22 |
| 合計ジャッジ時間 | 2,504 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 61 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <climits>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
using int64 = long long;
bool isPrime(const int& n) {
if (n==1 || (n!=2 && n%2==0) ) return false;
for (int i=3; i*i<=n; i++) {
if (n%i==0) return false;
}
return true;
}
int add_div(const int& n) {
int res = 0;
for (int i=1; i<n; i++) {
if (n%i==0) res += i;
}
return res;
}
int main() {
int n;
cin >> n;
if (isPrime(n)) cout << "Sosu!" << endl;
else if (n>1 && n == (int)sqrt(n) * (int)sqrt(n)) cout << "Heihosu!" << endl;
else if (n>1 && n == (int)cbrt(n) * (int)cbrt(n) * (int)cbrt(n)) cout << "Ripposu!" << endl;
else if (n!=0 && add_div(n) == n) cout << "Kanzensu!" << endl;
else cout << n << endl;
}