이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e7;
//const int N=15;
vector<tuple<int,int,int,int>> que;
bool ans[10];
bool comp[N+10];
int s[N+10];
vector<tuple<int,int,int>> srt;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin>>q;
for(int i=1;i<=q;i++)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
que.emplace_back(a,b,c,d);
srt.emplace_back(a-1,i-1,1);
srt.emplace_back(b,i-1,-1);
srt.emplace_back(c-1,i-1,-1);
srt.emplace_back(d,i-1,1);
}
sort(srt.begin(),srt.end());
for(int i=2;i<=N;i++)
{
if(comp[i])
continue;
int pref=0;
int it=0;
for(int j=i;j<=N;j+=i)
{
while(it<4*q)
{
auto [a,b,c]=srt[it];
if(a>=j)
break;
//cerr<<i<<" "<<a<<" "<<pref<<"\n";
s[b]+=c*pref;
it++;
}
comp[j]=true;
for(int tmp=j;tmp%i==0;tmp/=i,pref++);
}
while(it<4*q)
{
auto [a,b,c]=srt[it];
s[b]+=c*pref;
it++;
}
for(int it=0;it<q;it++)
{
if(s[it]<0)
ans[it]=true;
s[it]=0;
}
}
for(int i=0;i<q;i++)
cout<<(ans[i] ? "NE":"DA")<<"\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... |