이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#define N 200501
#define NN 10000010
#define PB push_back
#define M ll(1e9 + 7)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define _ << " " <<
#define pri(x) cout << x << endl
#define endl '\n'
#define F first
#define S second
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef long double ld;
//typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
bool mk[NN];
vector <int> pr;
int skok(int l, int r, ll x)
{
vector <int> vr; vr.clear();
vr.PB(x);
while (1ll * vr.back() * x <= 1ll * r)
vr.PB(vr.back() * x);
int val[sz(vr)], ans = 0;
for (int i = sz(vr) - 1; i >= 0; i--)
{
int kol = (r / vr[i]);
kol -= ((l - 1) / vr[i]);
for (int j = i + 1; j < sz(vr); j++)
kol -= val[j];
val[i] = kol;
ans += kol * (i + 1);
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("1.in", "r", stdin);
for (int i = 2; i < NN; i++)
{
if (mk[i]) continue;
pr.PB(i);
for (ll j = 1ll * i * i; j < NN; j += i)
mk[j] = 1;
}
int q;
cin >> q;
for (; q > 0; q--)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
bool gd = 1;
for (auto it : pr)
{
int l = skok(a, b, it);
int r = skok(c, d, it);
if (l > r)
{
gd = 0;
break;
}
}
if (gd)
{
pri("DA");
}
else
{
pri("NE");
}
}
}
# | 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... |