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;
#define ll long long
const int N = 2e5 + 5;
const int MOD = 1e9 + 7 ;
int gcd(int a, int b) {
return ((!b) ? a : gcd(b, a % b)) ;
}
int n, q, a[N] ;
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> q ;
for (int i = 1 ; i <= n ; i++) {
cin >> a[i] ;
}
for (int i = 1 ; i <= q ; i++) {
int cmd; cin >> cmd ;
if (cmd == 1) {
int index, x; cin >> index >> x ;
a[index] = x ;
} else {
int l, r; cin >> l >> r;
ll ret = 0 ;
for (int j = l ; j <= r ; j++) {
int cur = 0 ;
for (int k = j ; k <= r ; k++) {
cur = gcd(cur, a[k]) ;
if (cur == 1) break ;
ret++ ;
}
}
cout << ret << "\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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |