#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7;
const int N = 1e7 + 5;
const int INF = 1e9;
bool p[N];
int cnt[N];
vector<int> v;
void sieve(){
fill(p + 2 , p + N , 1);
for(int i = 2; i * i < N; i++){
if(p[i]){
for(int j = i * i; j < N; j += i)
p[j] = 0;
}
}
}
void solve()
{
int a , b , c , d;
cin >> a >> b >> c >> d;
fill(cnt , cnt + N , 0);
int n = d;
for(int i = 2; i <= n; i++){
if(!p[i]) continue;
int p = i;
while(p <= n){
cnt[i] += n / p;
p *= i;
}
}
n = a - 1;
for(int i = 2; i <= n; i++){
if(!p[i]) continue;
int p = i;
while(p <= n){
cnt[i] += n / p;
p *= i;
}
}
n = b;
for(int i = 2; i <= n; i++){
if(!p[i]) continue;
int p = i;
while(p <= n){
cnt[i] -= n / p;
p *= i;
}
}
n = c - 1;
for(int i = 2; i <= n; i++){
if(!p[i]) continue;
int p = i;
while(p <= n){
cnt[i] -= n / p;
p *= i;
}
}
for(int i = 2; i < N; i++){
if(!p[i]) continue;
if(cnt[i] < 0){
cout << "NE" << '\n';
return ;
}
}
cout << "DA" << '\n';
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
sieve();
int T = 1;
cin >> T;
while (T--)
solve();
}
# | 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... |