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 base = (int)(1e9 + 7);
const int man = (int)(1e7 + 10);
bool was[man];
vector <int> pr;
inline void cls() {}
int cnt(int x, int y) {
return (x / y);
}
int get(int lft, int rgt, int x) {
long long p = x;
int ret = 0;
while (p <= rgt) {
ret += cnt(rgt, p) - cnt(lft - 1, p);
p *= x;
}
return ret;
}
void solve() {
cls();
int a, b, c, d;
cin >> a >> b >> c >> d;
for (auto& i : pr) {
int x = get(a, b, i);
int y = get(c, d, i);
if ((y - x) < 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 <= 1e7; ++i) {
if (was[i]) {
continue;
}
pr.push_back(i);
if ((i * 1LL * i) <= 1e7) {
for (int j = (i * i); j <= 1e7; j += i) {
was[j] = true;
}
}
}
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... |