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 "game.h"
#include "bits/stdc++.h"
using namespace std;
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 st2[2000][2000][11];
int r, c;
void init(int R, int C) {
r = R;
c = C;
}
long long qry(int i, int l, int r) {
int k = 32 - __builtin_clz(r - l + 1) - 1;
return gcd2(st2[i][l][k], st2[i][r - (1<<k) + 1][k]);
}
void update(int P, int Q, long long K) {
if(max(r, c) <= 2000) {
st2[P][Q][0] = K;
for(int i=1; i<=10; i++) {
for(int j=0; j+(1<<i)-1<c; j++) {
st2[P][j][i] = gcd2(st2[P][j][i-1], st2[P][j + (1<<(i-1))][i-1]);
}
}
return;
}
}
long long calculate(int P, int Q, int U, int V) {
if(max(r, c) <= 2000) {
long long ans = 0;
for(int i=P; i<=U; i++) {
ans = gcd2(ans, qry(i, Q, V));
}
return ans;
}
}
/*
g++ -std=c++17 -O2 -o T2444 grador.cpp T2444.cpp
./T2444 < input.txt
*/
Compilation message (stderr)
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
47 | }
| ^
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |