이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,q,a,b,t;
cin >> n >> q;
vector<long long> haha(n+1,1);
for(long long i = 1; i <= n; i++) {
cin >> haha[i];
haha[i] = haha[i-1]*((haha[i]+haha[i-1]-1)/haha[i-1]);
haha[i] = min(haha[i],(long long)INT_MAX);
}
for(long long i = 0; i < q; i++) {
cin >> t >> a >> b;
long long c = a,ans = 0;
if(t >= c) {
long long l = 0,r = haha.size()-1;
while(l < r) {
long long mid = (l+r+1)/2;
if(-mid+haha[mid]*(t/haha[mid]) >= c) {
l = mid;
}
else {
r = mid-1;
}
}
ans+=l+1;
}
c = b+1;
if(t >= c) {
long long l = 0,r = haha.size()-1;
while(l < r) {
long long mid = (l+r+1)/2;
if(-mid+haha[mid]*(t/haha[mid]) >= c) {
l = mid;
}
else {
r = mid-1;
}
}
ans-=l+1;
}
cout << ans << "\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... |