#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define sqr(x) ((ll)(x))*(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int T;
int factorsLeft[10000000];
bool test(int c, int d) {
for (int i = c; i <= d; i++) {
int x = i;
while (x%2 == 0) { factorsLeft[2]--; x /= 2; if (factorsLeft[2] < 0) return false; }
for (int factor = 3; (ll)factor*factor <= x; factor+=2) {
while (x%factor == 0) { x /= factor; factorsLeft[factor]--; if (factorsLeft[factor] < 0) return false;}
}
if (x > 2) {
factorsLeft[x]--;
if (factorsLeft[x] < 0) return false;
}
}
return true;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> T;
FOR(testcase, 0, T) {
FOR(i, 0, 10000000) factorsLeft[i] = 0;
int a, b, c, d; cin >> a >> b >> c >> d;
for (int i = c; i <= d; i++) {
int x = i;
while (x%2 == 0) { factorsLeft[2]++; x /= 2; }
for (int factor = 3; (ll)factor*factor <= x; factor+=2) {
while (x%factor == 0) { x /= factor; factorsLeft[factor]++;}
}
if (x > 2) factorsLeft[x]++;
}
cout << (test(a, b)?"DA":"NE") << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
39444 KB |
Output is correct |
2 |
Correct |
51 ms |
39436 KB |
Output is correct |
3 |
Correct |
53 ms |
39508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
39380 KB |
Output is correct |
2 |
Correct |
55 ms |
39500 KB |
Output is correct |
3 |
Correct |
54 ms |
39392 KB |
Output is correct |
4 |
Correct |
54 ms |
39380 KB |
Output is correct |
5 |
Correct |
52 ms |
39356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
39380 KB |
Output is correct |
2 |
Correct |
52 ms |
39376 KB |
Output is correct |
3 |
Correct |
51 ms |
39396 KB |
Output is correct |
4 |
Correct |
52 ms |
39380 KB |
Output is correct |
5 |
Correct |
53 ms |
39364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1577 ms |
39372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1575 ms |
39380 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1569 ms |
39380 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1575 ms |
39376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |