結果
問題 |
No.2751 429-like Number
|
ユーザー |
|
提出日時 | 2024-05-10 22:01:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,189 bytes |
コンパイル時間 | 2,146 ms |
コンパイル使用メモリ | 202,056 KB |
最終ジャッジ日時 | 2025-02-21 12:46:12 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 -- * 5 |
other | -- * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using Matrix = vector<vector<ll>>; const int inf = 1000000000; const ll INF = 1000000000000000000; const ll mod = 998244353; const ull mod_hash = (1UL << 61) - 1; const vector<int> dx = {0, 1, 0, -1, 1, 1, -1, -1}; const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1}; struct Eratosthenes{ int N; vector<int> min_f; vector<int> prime; Eratosthenes(int N) : N(N){min_f.assign(N, 1000000000);} void build(){ min_f[0] = 1; min_f[1] = 1; for (int i = 2; i < N; i++) { for (int j = 2; i * j < N; j++) { min_f[i * j] = min(i, min_f[i * j]); } } for (int i = 0; i < N; i++) { if (min_f[i] != inf) continue; prime.push_back(i); } } }; int main(){ Eratosthenes e(2500); e.build(); set<ll> s; for (int i = 0; i < e.prime.size(); i++) { for (int j = i; j < e.prime.size(); j++) { for (int k = j; k < e.prime.size(); k++) { s.insert(e.prime[i] * e.prime[j] * e.prime[k]); } } } int Q;cin>>Q; while(Q--){ ll a;cin>>a; cout << (s.count(a) ? "Yes" : "No") << endl; } return 0; }