結果
| 問題 |
No.854 公平なりんご分配
|
| コンテスト | |
| ユーザー |
t33f
|
| 提出日時 | 2019-07-26 22:52:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,102 bytes |
| コンパイル時間 | 707 ms |
| コンパイル使用メモリ | 72,172 KB |
| 実行使用メモリ | 40,192 KB |
| 最終ジャッジ日時 | 2024-07-02 08:48:10 |
| 合計ジャッジ時間 | 10,538 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 1 WA * 49 TLE * 1 -- * 41 |
ソースコード
#include <cassert>
#include <vector>
#include <iostream>
using namespace std;
int B[100100][303] = {};
int main() {
vector<int> ps;
vector<bool> b(2001);
fill(b.begin(), b.end(), true);
for (int p = 2; p < 2000; p++)
if (b[p]) {
ps.push_back(p);
for (int q = p*p; q < 2000; q += p) b[q] = false;
}
assert(ps.size() == 303);
int n; cin >> n;
for (int i = 0; i < n; i++) {
int a; cin >> a;
for (int k = 0; k < ps.size(); k++) {
int p = ps[k], e = 0;
while (a % p == 0) { e++; a /= p; }
if (e > 0)
for (int j = i+1; j <= n; j += j&-j) B[j][k] += e;
}
}
int q; cin >> q;
while (q--) {
int l, r, x; cin >> x >> l >> r;
for (int k = 0; k < ps.size(); k++) {
int p = ps[k], e = 0;
for (int j = r; j > 0; j -= j&-j) e += B[j][k];
for (int j = l-1; j > 0; j -= j&-j) e -= B[j][k];
while (e > 0 && x % p == 0) x /= p, e--;
}
cout << (x == 1 ? "Yes" : "No") << endl;
}
}
t33f