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 <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> inline bool chmin(T& a, const T b) {a = min(a, b); return (a == b);}
template <typename T> inline bool chmax(T& a, const T b) {a = max(a, b); return (a == b);}
const int man = (int)(1e7 + 10);
bool was[man];
vector <int> prime;
vector <array <int, 2> > v[man];
inline void cls() {}
void solve() {
cls();
int a, b, c, d;
cin >> a >> b >> c >> d;
map <int, int> m1, m2;
for (int i = a; i <= b; ++i) {
for (auto& j : v[i]) {
m1[j[0]] += j[1];
}
}
for (int i = c; i <= d; ++i) {
for (auto& j : v[i]) {
m2[j[0]] += j[1];
}
}
for (auto& i : m2) {
if (i.second < m1[i.first]) {
cout << "NE\n";
return;
}
m1[i.first] = 0;
}
for (auto& i : m1) {
if (i.second != 0) {
cout << "NE\n";
return;
}
}
cout << "DA\n";
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// int t = 1;
#ifdef _LOCAL
system("color a");
freopen("in.txt", "r", stdin);
// cin >> t;
#endif
for (int i = 2; i <= 1e4; ++i) {
if (was[i]) {
continue;
}
prime.push_back(i);
if ((i * i) <= 1e4) {
for (int j = (i * i); j <= 1e4; j += i) {
was[j] = true;
}
}
}
for (int i = 2; i <= 1e4; ++i) {
int d = i;
vector <array <int, 2> > cur;
for (int j = 0; (j < (int)(prime.size())) && ((prime[j] * prime[j]) <= d); ++j) {
int cnt = 0;
while ((d % prime[j]) == 0) {
d /= prime[j];
++cnt;
}
if (cnt) {
cur.push_back({prime[j], cnt});
}
}
if (d != 1) {
cur.push_back({d, 1});
}
v[i] = cur;
}
int t;
cin >> t;
while (t--) {
solve();
}
// for (int i = 1; i <= t; ++i) {
// cerr << "Case #" << i << ": \n";
// solve();
// cerr << "\n";
// }
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |