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>
using namespace std;
const int N = 1e7+6;
int t,a,b,c,d;
bool vs[N];
vector<int> primes;
void precalc()
{
for (int i=2;i<=10000000;i++) {
if (!vs[i]) {
primes.push_back(i);
for (int j=i;j<=10000000;j+=i) {
vs[j] = true;
}
}
}
return;
}
int calc(int u,int v)
{
int k = 0;
while (u) {
k += u/v;
u /= v;
}
return k;
}
int main()
{
precalc();
cin >> t;
while (t--) {
cin >> a >> b >> c >> d;
a--;
c--;
bool y = true;
for (int u : primes) {
int p1,p4,p2,p3;
p1 = calc(a,u);
p2 = calc(b,u);
p3 = calc(c,u);
p4 = calc(d,u);
p2 -= p1;
p4 -= p3;
if (p2>p4) y = false;
}
if(y) cout << "DA\n";
else cout <<"NE\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... |