結果
問題 | No.2751 429-like Number |
ユーザー |
![]() |
提出日時 | 2024-05-10 22:46:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,152 bytes |
コンパイル時間 | 2,218 ms |
コンパイル使用メモリ | 202,468 KB |
最終ジャッジ日時 | 2025-02-21 13:03:41 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | WA * 1 TLE * 1 -- * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;bool is_prime(long long n) {if (n == 1) {return false;}for (long long i = 2; i * i <= n; i++) {if (n % i == 0) {return false;}}return true;}int main() {vector<bool> prime(100000, true);for (int i = 2; i < 100010; i++) {if (!prime[i]) {continue;}for (int j = i * 2; j < 100010; j += i) {prime[j] = false;}}vector<long long> p;for (int i = 2; i <= 10000; i++) {if (prime[i]) {p.push_back((long long)i);}}set<long long> s;for (auto x : p) {for (auto y : p) {s.insert(x * y);}}int q;cin >> q;while (q--) {long long a;cin >> a;bool ok = false;for (auto x : s) {if (a % x != 0) {continue;}long long b = a / x;if (is_prime(b)) {ok = true;break;}}cout << (ok ? "Yes" : "No") << endl;}}