Submission #1039442

#TimeUsernameProblemLanguageResultExecution timeMemory
1039442ArthuroWichGame (IOI13_game)C++17
0 / 100
1 ms348 KiB
#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; } int seg[100][4*100005]; void update(int n, int l, int r, int i, int v, int id) { if (l == r) { seg[id][n] = v; } else { int m = (l+r)/2; if (l <= i && i <= m) { update(2*n, l, m, i, v, id); } else { update(2*n+1, m+1, r, i, v, id); } seg[id][n] = gcd2(seg[id][2*n], seg[id][2*n+1]); } } int query(int n, int l, int r, int a, int b, int id) { if (b < l || r < a) { return 0; } else if (a <= l && r <= b) { return seg[id][n]; } else { int m = (l+r)/2; return gcd2(query(2*n, l, m, a, b, id), query(2*n+1, m+1, r, a, b, id)); } } void init(int R, int C) { } void update(int P, int Q, long long K) { update(1, 0, 100000, Q, K, P); } long long calculate(int P, int Q, int U, int V) { int x = 0; for (int i = P; i <= U; i++) { x = gcd2(x, query(1, 0, 100000, Q, V, i)); } return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...