Submission #942535

#TimeUsernameProblemLanguageResultExecution timeMemory
942535skywwlaGaraža (COCI17_garaza)C++17
0 / 160
4065 ms1624 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...