This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, q, t, x, v, l, r, cur, ans, a[100005];
int main(){
cin >> n >> q;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < q; i++){
cin >> t;
if(t == 1){
cin >> x >> v;
x--;
a[x] = v;
} else {
cin >> l >> r;
l--; r--; ans = 0;
for(int j = l; j <= r; j++){
cur = a[j];
for(int k = j; k <= r; k++){
cur = __gcd(cur, a[k]);
if(cur == 1) break;
ans++;
}
}
cout << ans << "\n";
}
}
}
# | 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... |