# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1259657 | comgaTramAnh | Game (IOI13_game) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
//#include "game.h"
long long gcd2(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[105][105];
void init(int R, int C) {
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
a[i][j] = 0;
}
}
}
void update(int P, int Q, long long K) {
a[P][Q] = K;
}
long long calculate(int P, int Q, int U, int V) {
long long ans = a[P][Q];
for (int i = P; i <= U; i++) {
for (int j = Q; j <= V; j++) {
ans = gcd2(ans, a[i][j]);
}
}
return ans;
}