結果

問題 No.889 素数!
ユーザー Ichimiya
提出日時 2020-06-21 05:35:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 172,512 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 17:47:09
合計ジャッジ時間 3,247 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	vector<int> pn, sn, cb;
	for (int i = 2; i < 65; i++) {
		int a, b;
		a = i * i;
		b = a * i;

		if (a <= 64) sn.push_back(a);
		if (b <= 64) cb.push_back(b);
	}
	for (int i = 2; i < 65; i++) {
		pn.push_back(i);
	}
	for (int i = 0; i < pn.size(); i++) {
		int n = pn.at(i);

		if (i < pn.size() - 1) {
			for (int j = i + 1; j < pn.size(); j++) {
				int& m = pn.at(j);
				if (m % n == 0) {
					m = 100;
				}
			}
		}
	}
	while (pn.at(pn.size() - 1) == 100) {
		pn.pop_back();
	}

	string s = to_string(N);
	if (N == 6 || N == 28) s = "Kanzensu!";
	if (count(pn.begin(), pn.end(), N) == 1) s = "Sosu!";
	if (count(sn.begin(), sn.end(), N) == 1) s = "Heihosu!";
	if (count(cb.begin(), cb.end(), N) == 1) s = "Ripposu!";

	cout << s << endl;
}
0