이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define task "reporter3"
#define lb lower_bound
#define ub upper_bound
#define ALL(v) (v).begin(),(v).end()
#define zs(v) ll((v).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(ll i=(a),_b=(b);i<=_b;++i)
#define per(i,b,a) for(ll i=(b),_a=(a);i>=_a;--i)
#define rep_(i,a,b) for(ll i=(a),_b=(b);i<_b;++i)
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const ll d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const ll mod=1000000007; /// 998244353
const ll base=311;
const ll N=5e5+5;
ll n,q,a[N];
ll b[N];
void biot()
{
cin>>n>>q;
for(ll i=1;i<=n;++i) cin>>a[i];
b[0]=1;
for(ll i=1;i<=n;++i)
{
b[i]=((a[i]+b[i-1]-1)/b[i-1])*b[i-1];
// cout<<b[i]<<' ';
}
// cout<<endl;
while(q--)
{
ll L,R,t;
cin>>t>>L>>R;
ll l=0, r=n;
ll ansl=-1, ansr=-1;
while(l<=r)
{
ll mid=(l+r)>>1;
if((t/b[mid])*b[mid]-mid>=L) l=mid+1, ansl=mid;
else r=mid-1;
}
l=0, r=n;
while(l<=r)
{
ll mid=(l+r)>>1;
if(t/b[mid]*b[mid]-mid<=R) r=mid-1, ansr=mid;
else l=mid+1;
}
cout<<ansl-ansr+1<<'\n';
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
biot();
}
컴파일 시 표준 에러 (stderr) 메시지
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
65 | freopen(task".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
66 | freopen(task".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |