# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
637477 | GusterGoose27 | popa (BOI18_popa) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "popa.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MAXN = 1000;
bool lr_par[MAXN]; // when we queried i, i+1, was it i or i+1
int n;
pii range[MAXN];
int rt;
int *l;
int *r;
int seq[MAXN];
int gcd(int a, int b) {
if (a > b) return gcd(b, a);
if (a == 0) return b;
return gcd(b%a, a);
}
bool query(int a, int b, int c, int d) {
int gcd1 = seq[a];
for (int i = a+1; i <= b; i++) gcd1 = gcd(gcd1, seq[i]);
int gcd2 = seq[c];
for (int i = c+1; i <= d; i++) gcd2 = gcd(gcd2, seq[i]);
return gcd1 == gcd2;
}