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>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e7+5;
int isprime[N];
vector<int> primes;
void init(){
fill(isprime,isprime+N,1);
for(int i = 2;i < N;i++){
if(isprime[i]){
primes.push_back(i);
for(int j = i*i;j < N;j += i){
isprime[j] = 0;
}
}
}
}
int val(int n, int p){
int res = 0;
while(n){
res += n/p;
n/=p;
}
return res;
}
void solve(){
int a,b,c,d;
cin >> a >> b >> c >> d;
//O(psize*4log_psize(C))
for(auto x : primes){
if(val(c-1,x)+val(b,x)>val(d,x)+val(a-1,x)){
cout << "NE\n";
return;
}
}
cout << "DA\n";
}
signed main(){
fastio
init();
int t;
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... |