이 제출은 이전 버전의 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);
int lp[man], cnt[man];
vector <int> prime;
inline void cls() {}
void solve() {
cls();
int a, b, c, d;
for (int i = 1; i <= 1e7; ++i) {
cnt[i] = 0;
}
cin >> a >> b >> c >> d;
for (int i = a; i <= b; ++i) {
int d = i;
while (d > 1) {
++cnt[lp[d]];
d /= lp[d];
}
}
for (int i = c; i <= d; ++i) {
int d = i;
while (d > 1) {
cnt[lp[d]] = max(cnt[lp[d]] - 1, 0);
d /= lp[d];
}
}
bool gd = true;
for (int i = 1; i <= 1e7; ++i) {
gd &= !cnt[i];
}
if (gd) {
cout << "DA\n";
} else {
cout << "NE\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 (lp[i] == 0) {
lp[i] = i;
prime.push_back(i);
}
for (int j = 0; (j < (int)(prime.size())) && (prime[j] <= lp[i]) && ((i * 1LL * prime[j]) <= 1e7); ++j) {
lp[i * prime[j]] = prime[j];
}
}
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... |