이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define fi first
#define se second
#define mp make_pair
using namespace std;
void db() {cout << endl;}
template <typename T, typename ...U> void db(T a, U ...b) {
//return;
cout << a << ' ', db(b...);
}
#ifdef Cloud
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define file ios::sync_with_stdio(false); cin.tie(0)
#endif
const int inf = 1e9 + 1, N = 1e7 + 1, mod = 1e9 + 7;
vector<int> p;
int cnt(int l, int r, int x){
return r / x - (l - 1) / x;
}
void solve(){
int a, b, c, d;
cin >> a >> b >> c >> d;
for (int i : p){
ll x = i, pre1 = 0, pre2 = 0, pw = 1, sum = 0;
while (x * i <= N) x *= i, pw++;
for (ll j = x; j > 1; j /= i){
sum += pw * (cnt(c, d, j) - pre1);
pre1 = cnt(c, d, j);
sum -= pw * (cnt(a, b, j) - pre2);
pre2 = cnt(a, b, j);
pw--;
}
if (sum < 0) return void(cout << "NE\n");
}
cout << "DA\n";
}
signed main(){
file;
bool out[N]{};
for (int i = 2; i < N; i++){
if (!out[i]) p.push_back(i);
for (int j : p){
if (j * i >= N) break;
out[j * i] = 1;
}
}
int t;
cin >> t;
while (t--) solve();
//db(p.size());
}
# | 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... |