#include<bits/stdc++.h>
#define ll long long
#include "game.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;
}
ll t[100][4*100001];
ll t1[2000][4*2001];
int pos,l,r,sd,R,C;
ll val;
void upd (int v,int tl,int tr) {
if (tl == tr) {
t[sd][v] = val;
return;
}
int tm = (tl + tr)/2;
if (pos <= tm) upd(v*2,tl,tm);
else upd(v*2|1,tm+1,tr);
t[sd][v] = gcd2(t[sd][v*2],t[sd][v*2|1]);
}
void upd1 (int v,int tl,int tr) {
if (tl == tr) {
t1[sd][v] = val;
return;
}
int tm = (tl + tr)/2;
if (pos <= tm) upd1(v*2,tl,tm);
else upd1(v*2|1,tm+1,tr);
t1[sd][v] = gcd2(t1[sd][v*2],t1[sd][v*2|1]);
}
ll get (int v,int tl,int tr) {
if (l > tr || r < tl) return 0;
if (l <= tl && r >= tr) {
return t[sd][v];
}
int tm = (tl + tr)/2;
return gcd2 ( get (v*2,tl,tm), get (v*2|1,tm+1,tr));
}
ll get1 (int v,int tl,int tr) {
if (l > tr || r < tl) return 0;
if (l <= tl && r >= tr) {
return t1[sd][v];
}
int tm = (tl + tr)/2;
return gcd2 ( get1 (v*2,tl,tm), get1 (v*2|1,tm+1,tr));
}
void update(int P, int Q, long long K) {
sd = P;
val = K; pos = Q;
if (C > 2000 || R > 2000)
upd (1,0,100000);
else upd1 (1,0,2000);
}
ll s;
long long calculate(int P, int Q, int U, int V) {
s = 0;
l = Q; r = V;
if (C > 2000 || R > 2000)
for (sd = P; sd <= U; sd++) {
s = gcd2(s,get (1,0,100000));
else
for (sd = P; i <= U; i++)
s = gcd2(s,get1 (1,0,2000));
}
return s;
}
void init(int R1, int C1) {R = R1; C = C1;}
Compilation message
grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int res;
^~~
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:70:5: error: 'else' without a previous 'if'
else
^~~~
game.cpp:71:19: error: 'i' was not declared in this scope
for (sd = P; i <= U; i++)
^