# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240681 | aryan12 | Game (IOI13_game) | C++17 | 0 ms | 0 KiB |
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;
long long gcd(long long X, long long Y) {
long long tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
long long a[102][102] = {{0}};
int main() {
long long R, C, Q;
cin >> R >> C >> Q;
while(Q--) {
long long command;
cin >> command;
if(command == 1) {
long long r, c, val;
cin >> r >> c >> val;
a[r][c] = val;
}
else {
long long ans = 0;
long long r1, c1, r2, c2;
cin >> r1 >> c1 >> r2 >> c2;
for(long long i = r1; i <= r2; i++) {
for(long long j = c1; j <= c2; j++) {
ans = gcd(ans, a[i][j]);
}
}
cout << ans << "\n";
}
}
}