이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1000000007;
int n, q;
LL d[500010];
LL findx(int num, LL t){
if(num==0)return t;
return t/d[num]*d[num]-(LL)num;
}
int f(int st, int fin, LL x, LL t){
if(st==fin)return st;
int mid=(st+fin)/2+1;
LL xx=findx(mid, t);
if(xx<x)return f(st, mid-1, x, t);
return f(mid, fin, x, t);
}
int g(int st, int fin, LL x, LL t){
if(st==fin)return st;
int mid=(st+fin)/2;
LL xx=findx(mid, t);
if(xx>x)return g(mid+1, fin, x, t);
return g(st, mid, x, t);
}
int main()
{
scanf("%d %d", &n, &q);
for(int i=1; i<=n; i++){
scanf("%lld", &d[i]);
if(i>1){
if(d[i]<d[i-1])d[i]=d[i-1];
d[i]=((d[i]-1)/d[i-1]+1)*d[i-1];
}
}
for(int i=1; i<=q; i++){
LL a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
int ff=f(0, n, b, a);
int gg=g(0, n, c, a);
if(a<b)ff=-1;
if(findx(n, a)>c)gg=n+1;
printf("%d\n", ff-gg+1);
}
}
컴파일 시 표준 에러 (stderr) 메시지
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &q);
~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &d[i]);
~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld", &a, &b, &c);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |