結果
| 問題 |
No.1349 Subset Product Queries
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-22 02:42:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 743 bytes |
| コンパイル時間 | 2,150 ms |
| コンパイル使用メモリ | 195,512 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-22 02:42:53 |
| 合計ジャッジ時間 | 8,087 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 5 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, P, Q;
cin >> N >> Q >> P;
vector<int> A(N);
for (int i = 0; i < N; ++i) cin >> A[i];
while (Q--) {
int L, R, K;
cin >> L >> R >> K;
--L; --R;
int len = R - L + 1;
bool found = false;
for (int mask = 1; mask < (1 << len); ++mask) {
long long prod = 1;
for (int i = 0; i < len; ++i) {
if (mask & (1 << i)) {
prod = (prod * A[L + i]) % P;
}
}
if (prod == K) {
found = true;
break;
}
}
cout << (found ? "Yes" : "No") << '\n';
}
return 0;
}