結果

問題 No.889 素数!
ユーザー tkmst201tkmst201
提出日時 2019-09-20 21:34:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,713 bytes
コンパイル時間 2,757 ms
コンパイル使用メモリ 155,672 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 18:12:07
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,356 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 1 ms
4,352 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,352 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 AC 1 ms
4,352 KB
testcase_32 AC 2 ms
4,480 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,352 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 1 ms
4,352 KB
testcase_39 AC 1 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,352 KB
testcase_44 AC 1 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 2 ms
4,352 KB
testcase_48 AC 1 ms
4,352 KB
testcase_49 AC 1 ms
4,348 KB
testcase_50 AC 1 ms
4,352 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 1 ms
4,352 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 1 ms
4,352 KB
testcase_55 AC 2 ms
4,352 KB
testcase_56 AC 1 ms
4,348 KB
testcase_57 AC 2 ms
4,352 KB
testcase_58 AC 1 ms
4,348 KB
testcase_59 AC 2 ms
4,352 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 1 ms
4,352 KB
testcase_62 AC 2 ms
4,352 KB
testcase_63 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

vector<int> sieve(int n) {
	vector<int> res;
	vector<bool> is_prime(n + 1, true);
	
	is_prime[0] = is_prime[1] = false;
	
	for (ll i = 2; i * i <= n; i++) if (is_prime[i]) {
		res.push_back(i);
		for (ll j = 1; i * j <= n; j++) is_prime[i * j] = false;
	}
	
	REP(i, n + 1) if (is_prime[i]) res.push_back(i);
	sort(res.begin(), res.end());
	return res;
}

vector<ll> findDivisor(ll n) {
	vector<ll> divisor;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divisor.push_back(i);
			if (i * i != n) divisor.push_back(n / i);
		}
	}
	return divisor;
}

int ans[64];
string str[5] = {"", "Sosu!", "Heihosu!", "Ripposu!", "Kanzensu!"};

int main() {
	int N;
	cin >> N;
	
	vector<int> prime = sieve(64);
	for (int cur : prime) ans[cur] = 1;
	
	ans[1] = 4;
	for (int i = 2; i < 64; i++) {
		if (i * i < 64) ans[i * i] = 2;
		if (i * i * i < 64) ans[i * i * i] = 3;
		
		vector<ll> divisor = findDivisor(i);
		int sum = accumulate(ALL(divisor), 0) - N;
		if (sum == i) ans[i] = 4;
	}
	
	if (ans[N] == 0) cout << N << endl;
	else cout << str[ans[N]] << endl;
	
	return 0;
}
0