結果
| 問題 |
No.889 素数!
|
| コンテスト | |
| ユーザー |
ate
|
| 提出日時 | 2019-11-06 14:31:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,911 bytes |
| コンパイル時間 | 2,616 ms |
| コンパイル使用メモリ | 201,900 KB |
| 最終ジャッジ日時 | 2025-01-08 02:21:52 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 61 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
6 | main(){
| ^~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
main(){
ll n;
cin>>n;
auto prime_enumeration = [](ll n){
vector<ll> primes;
for(ll x=2;x<=n;++x){
primes.emplace_back(x);
for(ll p=2;p*p<=x;++p){
if(x%p==0){
primes.pop_back();
break;
}
}
}
return primes;
};
auto square_enumeration = [](ll n){
vector<ll> squares;
for(ll p=2;p*p<=n;++p){
squares.emplace_back(p*p);
}
return squares;
};
auto cubic_enumeration = [](ll n){
vector<ll> cubics;
for(ll p=2;p*p*p<=n;++p){
cubics.emplace_back(p*p*p);
}
return cubics;
};
auto divior_enumeration = [](ll n){
vector<ll> divisors = {1};
for(ll p=2;p*p<=n;++p){
if(n%p==0){
divisors.emplace_back(p);
if(p*p!=n)divisors.emplace_back(n/p);
}
}
sort(divisors.begin(),divisors.end());
return divisors;
};
auto vector_sum = [](vector<ll> const& v){
ll sum = 0;
for(auto const& value:v)sum+=value;
return sum;
};
auto full_enumeration = [&](ll n){
vector<ll> full_number;
for(ll p=2;p<=n;++p){
auto div = divior_enumeration(p);
ll divsum = vector_sum(div);
if(p==divsum)full_number.emplace_back(p);
}
return full_number;
};
vector<ll> primes = prime_enumeration(n);
vector<ll> squares = square_enumeration(n);
vector<ll> cubics = cubic_enumeration(n);
vector<ll> fulls = full_enumeration(n);
auto _find = [](vector<ll>const& v,ll key){
for(auto const& value:v){
if(value==key)return true;
}
return false;
};
if(_find(primes,n)){
puts("Sosu!");
}
else if(_find(squares,n)){
puts("Heihosu!");
}
else if(_find(cubics,n)){
puts("Ripposu!");
}
else if(_find(fulls,n)){
puts("Kanzensu!");
}
else{
cout<<n<<endl;
}
}
ate