結果

問題 No.889 素数!
ユーザー pirozhki
提出日時 2019-10-09 23:25:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 1,257 ms
コンパイル使用メモリ 78,296 KB
最終ジャッジ日時 2025-01-07 21:23:47
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n; cin >> n;
	if (n == 0 || n == 1) {
		cout << n << endl;
	    return 0;
	}
	int i = 1, k = 0;
	bool sosu = true;
	while (i <= n/2) {
		if ((i != 1) && (n % i == 0)) {
			sosu = false;
		}
		if (n == int(pow(i, 2))) {
			cout << "Heihosu!" << endl;
			return 0;
		}
		if (n == int(pow(i, 3))) {
			cout << "Ripposu!" << endl;
			return 0;
		}
		if (n % i == 0) {
			k += i;
		}
		i++;
	}
	if (k == n) {
		cout << "Kanzensu!" << endl;
		return 0;
	}
	if (sosu) {
		cout << "Sosu!" << endl;
		return 0;
	}
	cout << n << endl;
	return 0;
}
0