이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |