結果
問題 | No.889 素数! |
ユーザー |
![]() |
提出日時 | 2019-09-20 21:28:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 890 bytes |
コンパイル時間 | 1,731 ms |
コンパイル使用メモリ | 171,820 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 16:22:42 |
合計ジャッジ時間 | 3,424 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; template<class Z> bool is_prime(Z n) { if (n < 2 or n > 2 and ~n & 1) return false; for (Z i = 3; i * i <= n; i += 2) if (n % i == 0) return false; return true; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); V<string> res(64); for (int i = 0; i < 64; ++i) { if (is_prime(i)) { res[i] = "Sosu!"; continue; } int t = sqrt(i) + 0.5; if (i >= 2 and t * t == i) { res[i] = "Heihosu!"; continue; } t = cbrt(i) + 0.5; if (i >= 2 and t * t * t == i) { res[i] = "Ripposu!"; continue; } if (i == 6 or i ==28) { res[i] = "Kanzensu!"; continue; } res[i] = to_string(i); } int n; cin >> n; cout << res[n] << '\n'; }