#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[100005], n, q;
int f(int t, int x)
{
int l=0, r=n+1;
while (l<r)
{
int m=(l+r)/2;
if (t/a[m]*a[m]-m<=x)
r=m;
else
l=m+1;
}
return n-r+2;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
a[0]=1;
for (int i=1; i<=n; i++)
{
cin >> a[i];
a[i]=((a[i]-1)/a[i-1]+1)*a[i-1];
}
for (int i=1; i<=q; i++)
{
int t, l, r;
cin >> t >> l >> r;
cout << f(t, r)-f(t, l-1) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |