이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3oIUrY0 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
const int _n=1e7+20;
ll a[_n+10],b[_n+10];
bool sv[_n+10];
int main(){
_3oIUrY0;
for(int i=2;i<=_n;i++){
if(sv[i]) continue;
for(int j=2*i;j<=_n;j+=i){
if(sv[j]==0) sv[j]=i;
}
}
vi prms;
for(int i=2;i<=_n;i++){
if(!sv[i]){
prms.pb(i);
}
}
auto f=[&](int prm,int n)->ll{
if(prm>n) return 0;
ll x=prm;
vi rbts;
while(x<=n){
rbts.pb(x);
x*=prm;
}
ll now=0;
for(auto x : rbts){
now+=(ll)(n/x);
}
return now;
};
int t;
cin>>t;
rep(cs,t){
int _a,_b,_c,_d;
cin>>_a>>_b>>_c>>_d;
for(auto prm : prms){
b[prm]+=f(prm,_b);
b[prm]-=f(prm,_a-1);
a[prm]+=f(prm,_d);
a[prm]-=f(prm,_c-1);
}
bool pok=1;
for(auto prm : prms){
if(b[prm]>a[prm]){
pok=0;
}
a[prm]=b[prm]=0;
}
cout<<(pok?"DA":"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... |