結果
問題 | No.2751 429-like Number |
ユーザー |
|
提出日時 | 2024-05-10 22:15:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,231 ms / 4,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 2,002 ms |
コンパイル使用メモリ | 195,608 KB |
最終ジャッジ日時 | 2025-02-21 12:53:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int MX = 100'010; bool table[MX + 10]; vector<ll> pns; void precalc() { rep(i, MX) { if (i <= 1) table[i] = true; if (table[i]) continue; pns.push_back(i); for (ll j = i * 2; j < MX; j += i) table[j] = true; } } void solve() { ll a; cin >> a; ll cnt = 0; bool ok = true; for (const auto pn : pns) { if (!ok || a < pn) break; while (a % pn == 0) { a /= pn; cnt += 1; if (cnt > 3) { ok = false; break; } } } ok &= (cnt == 3 && a == 1) || (cnt == 2 && a > 1); cout << (ok ? "Yes" : "No") << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; cin >> T; precalc(); for (int t = 0; t < T; t++) { solve(); } return 0; }