text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; long long find(long long a, long long b) { long long res = 0; while (a > 0) { res += a % b; a /= b; } return res; } int32_t main() { long long t, z; cin >> t; while (t--) { z = 0; long long a, b; cin >> a >> b; if (a == 0 or b == 0) cout << "Second"; while (a > 0 and b > 0) { if (a < b) swap(a, b); if (a % b == 0) { if (z == 0) cout << "First"; else cout << "Second"; break; } long long zz = a / b % (b + 1); if (zz % 2 == 0) { if (z == 0) cout << "First"; else cout << "Second"; break; } a = a % b; z = 1 - z; } cout << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; using llint = long long; bool solve(llint a, llint b) { if (a > b) swap(a, b); if (!a) return false; if (!solve(b % a, a)) return true; return b / a % (a + 1) % 2 == 0; } int main() { int t; scanf("%d", &t); while (t--) { llint a, b; scanf("%lld%lld", &a, &b); puts(solve(a, b) ? "First" : "Second"); } }
#include <bits/stdc++.h> using namespace std; int test; long long a, b; bool win(long long a, long long b) { if (b == 0) return false; if (!win(b, a % b)) return true; if (((a / b) % (b + 1)) & 1) return false; return true; } int main() { scanf("%d", &test); for (int i = 0; i < test; ++i) { scanf("%I64d %I64d", &a, &b); if (a < b) swap(a, b); if (win(a, b)) puts("First"); else puts("Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b; int dfs(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return 0; if (dfs(b % a, a)) { b -= b % a; b /= a; if (a % 2) return b % 2 ? 0 : 1; else return (b % (a + 1)) % 2 ? 0 : 1; } else return 1; } void main2() { scanf("%lld %lld", &a, &b); if (dfs(a, b)) printf("First\n"); else printf("Second\n"); } int TC; int main() { scanf("%d", &TC); while (TC--) main2(); }
#include <bits/stdc++.h> using namespace std; bool solve(long long a, long long b) { if (!a || !b) return false; if (a > b) swap(a, b); if (!solve(a, b % a)) return true; long long t = b / a, tt = a + 1; return (t % tt) % 2 == 0; } int main() { int T; scanf("%d", &T); while (T--) { long long a, b; scanf("%I64d %I64d", &a, &b); puts(solve(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; bool solve(long long a, long long b) { if (!a || !b) return false; if (a > b) swap(a, b); if (!solve(a, b % a)) return true; long long t = b / a, tt = a + 1; return (t % tt) % 2 == 0; } int main() { int T; scanf("%d", &T); while (T--) { long long a, b; scanf("%I64d %I64d", &a, &b); puts(solve(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> void max_swap(T& a, const T& b) { a = max(a, b); } template <class T> void min_swap(T& a, const T& b) { a = min(a, b); } const double EPS = 1e-8; const double PI = acos(-1.0); const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; } bool win(long long a, long long b) { if (a == 0) return false; if (!win(b % a, a)) return true; return ((b / a) % (a + 1)) % 2 == 0; } int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long a, b; cin >> a >> b; if (a > b) swap(a, b); cout << (win(a, b) ? "First" : "Second") << endl; } }
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = 3.1415926535897932384626433832795; const string task = ""; template <class T> T sqr(T x) { return x * x; } int solve(long long a, long long b) { long long w = (b / a) % (a + 1); return (w + 1) % 2; } int calc(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return 0; if (!calc(b % a, a)) return 1; if (solve(a, b - b % a)) return 1; return 0; } void solve() { long long a, b; cin >> a >> b; if (calc(a, b)) puts("First"); else puts("Second"); } long long gen() { long long mod = 1e18; long long now = rand(); now = (now << 48 | rand()); now = (now % mod + mod) % mod; return now; } int main() { int tst; cin >> tst; for (int i = 0; i < (int)(tst); i++) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = double; using vll = vector<ll>; using vvll = vector<vector<ll>>; bool f(ll a, ll b) { if (a == 0) return false; if (!f(b % a, a)) return true; ll x = b / a, mod = a + 1; return ((x % mod) % 2) == 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); ll t; cin >> t; while (t--) { ll a, b; cin >> a >> b; if (a > b) swap(a, b); cout << (f(a, b) ? "First" : "Second") << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int ca, cnt; long long a, b; bool get(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return 0; int tmp = get(b % a, a); if (tmp == 0) return 1; b /= a; if (a & 1) return !(b & 1); return (!((b % (a + 1)) & 1)); } int main() { for (scanf("%d", &ca); ca--;) { scanf("%I64d%I64d", &a, &b); cnt = get(a, b); if (cnt) puts("First"); else puts("Second"); } return 0; }
#include <bits/stdc++.h> inline bool num(long long a, long long b) { if (!a || !b) return false; if (!num(b % a, a)) return true; long long p = (b / a - 1) % (a + 1); return p & 1 || p == a; } long long t, a, b; int main() { scanf("%lld", &t); for (int i = 1; i <= t; i++) { scanf("%lld %lld", &a, &b); if (a > b) std::swap(a, b); printf(num(a, b) ? "First" : "Second"); if (i != t) putchar('\n'); } }
#include <bits/stdc++.h> template <class t> inline void read(t &s) { s = 0; register long long f = 1; register char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar(); s *= f; return; } template <class t, class... A> inline void read(t &x, A &...a) { read(x); read(a...); } template <class t> inline void write(t x) { if (x < 0) putchar('-'), x = -x; long long buf[21], top = 0; while (x) buf[++top] = x % 10, x /= 10; if (!top) buf[++top] = 0; while (top) putchar(buf[top--] ^ '0'); return; } inline void setIn(std::string s) { freopen(s.c_str(), "r", stdin); return; } inline void setOut(std::string s) { freopen(s.c_str(), "w", stdout); return; } inline void setIO(std::string s = "") { setIn(s + ".in"); setOut(s + ".out"); return; } template <class t> inline bool checkmin(t &x, t y) { if (x > y) { x = y; return 1; } return 0; } template <class t> inline bool checkmax(t &x, t y) { if (x < y) { x = y; return 1; } return 0; } inline long long lowbit(long long x) { return x & (-x); } inline long long f(long long x, long long y) { if (x > y) std::swap(x, y); if (!x) return 0; if (x == 1) return 1; if (!f(x, y % x)) return 1; return (((y / x) % (x + 1)) & 1) ^ 1; } inline void work() { long long x, y; read(x, y); std::puts(f(x, y) ? "First" : "Second"); } signed main(void) { long long t; read(t); while (t--) work(); return 0; }
#include <bits/stdc++.h> bool calc(long long a, long long b) { if (a < b) return calc(b, a); if (!b) return false; if (!calc(b, a % b)) return true; long long x = a / b - 1; if (b & 1) return x & 1; else return (x % (b + 1) == b) || ((x % (b + 1)) & 1); } int main() { int t; scanf("%d", &t); while (t--) { long long a, b; scanf("%I64d%I64d", &a, &b); if (calc(a, b)) puts("First"); else puts("Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200005; bool solve(long long a, long long b) { if (a > b) swap(a, b); if (!a) return 0; if (!solve(a, b % a)) return 1; if (a & 1) { return (b / a) % 2 == 0; } else { return ((b / a) % (a + 1)) % 2 == 0; } } int main() { long long a, b; int tc; cin >> tc; while (tc--) { scanf("%I64d %I64d", &a, &b); puts(solve(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> inline bool solve(long long a, long long b) { if (!a || !b) return 0; if (!solve(b % a, a)) return 1; long long k = (b / a - 1) % (a + 1); return (k & 1) || (k == a); } int main() { int T; long long a, b; scanf("%d", &T); while (T--) { scanf("%lld %lld", &a, &b); if (a > b) a ^= b, b ^= a, a ^= b; if (solve(a, b)) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int dp[100][100]; vector<long long> can; int test; int r(long long a, long long b) { if ((a == 0) || (b == 0)) return 0; int k = r(b % a, a); if (k == 0) return 1; long long v = (b % a); v += a; long long c = (b - v) / a; if (a & 1) { int res = (c & 1); return res; } c %= (a + 1); if (c == a) return 1; int res = (c & 1); return res; } int brut(int a, int b) { if (dp[a][b] != -1) return dp[a][b]; if ((a == 0) || (b == 0)) return 0; int res = brut(b % a, a); if (res == 0) return dp[a][b] = 1; int v = a; while (b - v >= 0) { int nb = b - v; res = min(res, brut(min(nb, a), max(nb, a))); v *= a; } res ^= 1; return dp[a][b] = res; } int main() { int t; scanf("%d", &t); while (t--) { long long a, b; cin >> a >> b; if (a > b) swap(a, b); int res = r(a, b); if (res) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int add(int a, int b) { if ((a += b) >= P) a -= P; return a; } int sub(int a, int b) { if ((a -= b) < 0) a += P; return a; } int mul(int a, int b) { return 1ll * a * b % P; } int kpow(int a, int b) { int r = 1; for (; b; b >>= 1, a = mul(a, a)) { if (b & 1) r = mul(r, a); } return r; } long long a, b; bool solve(long long a, long long b) { if (a == 0) return 0; bool t = solve(b % a, a); if (!t) return 1; long long x = b / a - 1; if (a & 1) { return (x & 1); } else { x %= (a + 1); return (x & 1) || x == a; } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int T; cin >> T; while (T--) { cin >> a >> b; if (a > b) swap(a, b); cout << (solve(a, b) ? "First" : "Second") << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; bool solve(unsigned long long a, unsigned long long b) { if (b == 0) return false; bool res = solve(b, a % b); if (!res) return true; unsigned long long c = (a - b) / b; if (b & 1) return c & 1; unsigned long long k = c % (b + 1); return (k & 1) || (k == b); } int main(void) { unsigned long long a, b; int i, n; cin >> n; for (i = 0; i < n; ++i) { cin >> a >> b; if (a < b) swap(a, b); if (solve(a, b)) cout << "First" << endl; else cout << "Second" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; bool can_win(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return false; if (!can_win(b % a, a)) return true; long long x = b / a % (a + 1); if (x < a) return x % 2 == 0; else return a % 2 == 0; } int main() { int t; scanf("%d", &t); while (t--) { long long a, b; scanf("%I64d%I64d", &a, &b); bool win = can_win(a, b); if (win) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int MXN = 410; const int MXK = 10; const int INF = (int)1e9; const long long LINF = (long long)1e18; const int mod = 1000000007; int solve(long long a, long long b) { if (!b) return 0; int s = 0; long long r = a % b; long long t = a / b - 1; int ppc = !solve(b, r); if (ppc) return 1; else if ((t % (b + 1)) & 1 || (t % (b + 1)) == b) return 1; else return 0; } int main() { int t; scanf("%d", &t); long long a, b; for (int i = (0); i < (t); i++) { scanf("%lld%lld", &a, &b); int q = solve(max(a, b), min(a, b)); if (!q) printf("Second\n"); else printf("First\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; class P { public: long long a, b; P(long long _a, long long _b) { a = _a; b = _b; if (a < b) swap(a, b); } }; vector<P> bench; void GCD(long long a, long long b) { bench.push_back(P(a, b)); if (a < b) swap(a, b); if (b != 0) GCD(a % b, b); } long long digitSum(long long m, long long b) { long long ans = 0; while (m) { ans += m % b; m /= b; } return ans; } int main() { int t, i; long long a, b, m, bb; bool W[1000]; scanf("%d", &t); while (t--) { scanf("%I64d %I64d", &a, &b); bench.clear(); GCD(a, b); reverse(bench.begin(), bench.end()); W[0] = false; for (i = 1; i < bench.size(); i++) { if (!W[i - 1]) { W[i] = true; continue; } m = bench[i].a / bench[i].b; bb = bench[i].b; if ((m - (m / (bb + 1)) * (bb + 1)) & 1) W[i] = false; else W[i] = true; } if (W[bench.size() - 1]) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; map<pair<long long, long long>, bool> memo; bool win(long long a, long long b) { if (a < b) { long long t = a; a = b; b = t; } pair<long long, long long> pp; pp = make_pair(a, b); if (b == 0) return false; if (memo.count(pp)) return memo[pp]; if (!win(b, a % b)) return true; int move = 0; long long x = a / b, mod = b + 1; return memo[pp] = ((x % mod) % 2 == 0); } int main() { int T; cin >> T; long long a, b; for (int t = 0; t < T; ++t) { cin >> a >> b; bool ans = win(a, b); if (ans) cout << "First\n"; else cout << "Second\n"; } }
#include <bits/stdc++.h> using namespace std; inline bool win(long long a, long long b) { if (a == 0 || b == 0) return 0; if (a > b) swap(a, b); if (!win(b % a, a)) return 1; long long n = b / a; return (n % (a + 1)) % 2 == 0; } int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long a, b; cin >> a >> b; if (win(a, b)) cout << "First\n"; else cout << "Second\n"; } return 0; }
#include <bits/stdc++.h> long long f(long long a, long long b) { return b ? !f(b, a % b) || 1 - a / b % (b + 1) % 2 : 0; } int main() { long long a, b, t; for (std::cin >> t; t--;) std::cin >> a >> b, a < b ? (a ^= b ^= a ^= b) : 0, puts(f(a, b) ? "First" : "Second"); }
#include <bits/stdc++.h> using namespace std; bool win(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return false; if (!win(b % a, a)) return true; long long df = b - b % a; if (a % 2) return df % 2 == 0; return df / a % (a + 1) % 2 == 0; } void solve() { long long a, b; cin >> a >> b; if (win(a, b)) cout << "First" << endl; else cout << "Second" << endl; } int main() { ios_base::sync_with_stdio(0); int T; cin >> T; for (int _ = 0; _ < (int)(T); _++) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, A, B; const long long N = 110; long long sg[N]; bool dfs(long long A, long long B) { if (A > B) swap(A, B); if (A == 1) return true; if (A == 0) return false; bool ok = dfs(B % A, A); if (!ok) return true; else { long long s = B / A; if (A & 1) { if (s & 1) return false; else return true; } else { s %= (A + 1); if (s & 1) return false; return true; } } } int main() { int T; scanf("%d", &T); while (T) { T--; scanf("%I64d%I64d", &A, &B); if (dfs(A, B)) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; bool solve(long long a, long long b) { if (a > b) return solve(b, a); assert(a <= b); if (a == 0LL) return false; long long mod = b % a; if (!solve(mod, a)) return true; long long dist = (b - mod) / a; if (a % 2) { return dist % 2 == 0; } else { long long x = dist % (a + 1); return x % 2 == 0; } } int main() { long long T; scanf("%I64d", &T); while (T--) { long long a, b; scanf("%I64d %I64d", &a, &b); puts(solve(a, b) ? "First" : "Second"); } }
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18 + 7; const long long mod = 1e9 + 7; const double eps = 1e-9; const double PI = 2 * acos(0.0); const double E = 2.71828; map<pair<long long, long long>, long long> now; int dfs(long long a, long long b) { if (a > b) swap(a, b); bool was = now.count(make_pair(a, b)); long long &res = now[make_pair(a, b)]; if (!a) return res = 0; if (was) return res; res = max(res, (long long)dfs(a, b % a) ^ 1); long long x = b / a - 1; if (a % 2 == 1) { res = max(res, x % 2); } else { x %= a + 1; res = max(res, x % 2); if (x == a) res = 1; } return res; } int main(void) { int t; scanf("%d", &t); for (int(i) = 0; (i) < (t); ++(i)) { long long x, y; cin >> x >> y; puts(dfs(x, y) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; bool fwin(long long a, long long b) { if (!a || !b) return false; if (a < b) swap(a, b); if (a % b == 0) return true; if (!fwin(b, a % b)) return true; long long k = a / b % (b + 1); return !(k & 1); } int main() { int t; long long a, b; scanf("%d", &t); while (t--) { scanf("%I64d %I64d", &a, &b); puts(fwin(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; bool gcd(long long x, long long y) { if (x == 0) { return false; } bool next = gcd(y % x, x); if (next == false) { return true; } else { long long k = y / x; if (x % 2) { return k % 2 == 0; } else { return k % (x + 1) % 2 == 0 || k % (x + 1) == x; } } } int main() { int n; cin >> n; while (n--) { long long x, y; cin >> x >> y; if (x > y) { x ^= y ^= x ^= y; } if (gcd(x, y)) { cout << "First" << endl; } else { cout << "Second" << endl; } } return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16777216") using namespace std; int dp[210][210]; bool check(long long a, long long b) { if (a == 0) return true; if (a == 1) return false; if (check(b % a, a)) return false; long long q = 1; long long r = 0; long long bb = b / a - 1; while (b / a / q > 0) q *= a; while (q > 1) { r += b / q; b %= q; q /= a; } if (a & 1) return r & 1; else return !((bb + 1) % (a + 1) == 0 || (bb % (a + 1)) & 1); } int main() { int tt; long long a, b; scanf("%d", &tt); for (int(t) = 0; (t) < (tt); ++(t)) { cin >> a >> b; if (a > b) swap(a, b); if (!check(a, b)) { printf("First\n"); continue; } printf("Second\n"); } return 0; }
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; bool win(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return false; if (a == 1) return true; if (!win(a, b % a)) return true; if (a & 1) return !(b / a % 2); return (b / a % (a + 1) % 2 == 0); } int main() { int t; long long a, b; for (scanf("%d", &t); t--;) { scanf("%I64d%I64d", &a, &b); printf(win(a, b) ? "First\n" : "Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b; int testy; bool check(long long a, long long b) { if (a == 0LL || b == 0LL) return false; if (a > b) swap(a, b); if (!check(b % a, a)) return true; long long wiel = b / a - 1; if (a & 1LL) return (wiel & 1LL); return (((wiel % (a + 1)) & 1LL) || wiel % (a + 1) == a); } int main() { (scanf("%d", &testy) ?: 0); while (testy--) { (scanf("%I64d%I64d", &a, &b) ?: 0); puts(check(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T& x) { bool fu = 0; char c; for (c = getchar(); c <= 32; c = getchar()) ; if (c == '-') fu = 1, c = getchar(); for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0'; if (fu) x = -x; }; template <class T> inline void read(T& x, T& y) { read(x); read(y); } template <class T> inline void read(T& x, T& y, T& z) { read(x); read(y); read(z); } inline char getc() { char c; for (c = getchar(); c <= 32; c = getchar()) ; return c; } long long a, b; bool solve(long long a, long long b) { if (a > b) return solve(b, a); if (a == 0) return 0; if (!solve(a, b % a)) return 1; if ((b / a) % (a + 1) % 2 == 0) return 1; return 0; } int main() { int T; for (read(T); T; T--) { read(a, b); if (solve(a, b)) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; long long T, a, b; bool work(long long a, long long b) { if (a > b) swap(a, b); if (!a) return 0; if (!work(a, b % a)) return 1; long long c = b / a; return !(a & 1 ? c & 1 : c % (a + 1) & 1); } int main() { cin >> T; while (T--) cin >> a >> b, puts(work(a, b) ? "First" : "Second"); return 0; }
#include <bits/stdc++.h> using namespace std; bool ok(long long a, long long b) { if (a == 0 || b == 0) return 0; if (a > b) swap(a, b); if (!ok(a, b % a)) return 1; long long N = b / a; long long M = a + 1; return ((N % M) % 2 == 0); } long long A, B; int main() { int t; cin >> t; while (t--) { cin >> A >> B; bool yes = ok(A, B); if (yes) puts("First"); else puts("Second"); } }
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; int T; long long a, b; bool go(long long x, long long y) { if (!x || !y) return false; bool res = go(y % x, x); if (!res) return true; long long bit = y / x % (x + 1); if (bit & 1) return false; return true; } void solve() { scanf("%lld%lld", &a, &b); if (a > b) swap(a, b); bool res = go(a, b); if (res) puts("First"); else puts("Second"); return; } int main() { for (scanf("%d", &T); T--; solve()) ; return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b; bool win(long long a, long long b) { if (a == 0 || b == 0) return false; if (a > b) swap(a, b); if (win(a, b % a) == false) return true; return (b / a) % (a + 1) % 2 == 0; } int main() { int T; cin >> T; while (T--) { long long a, b; cin >> a >> b; if (win(a, b) == true) cout << "First\n"; else cout << "Second\n"; } }
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int MM = 998244353; const long double PI = acos(-1); template <typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amax(T &x, U y) { if (x < y) x = y; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << '(' << p.first << "," << p.second << ')'; } map<pair<int64_t, int64_t>, bool> dp; bool go(int64_t a, int64_t b) { if (a > b) swap(a, b); if (b % a == 0) return true; if (dp.count({a, b})) return dp[{a, b}]; bool &ans = dp[{a, b}]; if (!go(b % a, a)) ans = true; else { if (a & 1) ans = ((b - b % a) / a) % 2 == 0; else ans = (((b - b % a) / a % (a + 1)) % 2 == 0); } return ans; } int _runtimeTerror_() { int64_t a, b; cin >> a >> b; if (a == 0 || b == 0) { cout << "Second\n"; return 0; } dp.clear(); bool ans = go(a, b); cout << (ans ? "First" : "Second") << "\n"; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int TESTS = 1; cin >> TESTS; while (TESTS--) _runtimeTerror_(); return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int inf = (int)1e9; int good(long long num, long long a) { long long d = num % (a + 1); if (d == a) return 1; return d % 2 == 1; } int go(long long a, long long b) { if (a == 0) return 0; int res = go(b % a, a); if (res == 0) return 1; else return good(b / a - 1, a); } int main() { int tn; scanf("%d", &tn); while (tn-- > 0) { long long a, b; scanf( "%lld" "%lld", &a, &b); if (a > b) swap(a, b); int res = go(a, b); if (res == 0) printf("Second\n"); else printf("First\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; void ch_max(int &x, int y) { if (x < y) x = y; } void ch_min(int &x, int y) { if (x > y) x = y; } const double pi = acos(-1.0); const double eps = 1e-9; bool solve(long long a, long long b) { if (a == 0 || b == 0) return false; if (a < b) swap(a, b); if (a % b == 0) return true; if (!solve(a % b, b)) return true; long long t0 = a / b; long long t1 = t0 % (b + 1); if (t1 % 2) return false; return true; } int main() { int i, j, k, t, nc = 0; scanf("%d", &t); while (t--) { long long a, b; scanf("%I64d%I64d", &a, &b); if (solve(a, b)) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; string s[] = {"First", "Second"}; long long f(long long x, long long y) { if (!x || !y) return 0; long long a = min(x, y); long long b = max(x, y); if (f(b % a, a)) { b /= a; return !((b % (a + 1)) & 1); } return 1; } signed main() { long long T; cin >> T; while (T--) { long long x, y; cin >> x >> y; cout << s[!f(x, y)] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void sc(char& c) { char temp[4]; scanf("%s", temp); c = temp[0]; } struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << " "; return *this; } } dbg; void debugarr(int* arr, int n) { cout << "["; for (int i = 0; i < n; i++) cout << arr[i] << " "; cout << "]" << endl; } int testnum; long long a, b; int win(long long n, long long a) { n %= (a + 1); if ((n & 1) == 0 && n != a) return 0; return 1; } int memo(long long a, long long b) { if (b < a) swap(a, b); if (a == 0) return 2; if (memo(a, b % a) == 2) return 1; long long steps = b / a - 1; if (win(steps, a)) return 1; else return 2; } void preprocess() {} void solve() { int win = memo(a, b); if (win == 1) printf("First\n"); else printf("Second\n"); } bool input() { scanf("%I64d", &a); scanf("%I64d", &b); return true; } int main() { preprocess(); int T; scanf("%d", &T); for (testnum = 1; testnum <= T; testnum++) { if (!input()) break; solve(); } }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:256000000") using namespace std; map<pair<long long, long long>, int> F; int calc(long long a, long long b) { if (a > b) { swap(a, b); } if (a == 0 || b == 0) { return 2; } if (b % a == 0) { return 1; } if (a <= 2000000000LL) { long long d = a; if (a % 2LL == 0LL) { d *= (a + 1LL); } else { d *= (a - 1LL); } b -= ((b - a - 1LL) / d) * d; if (b + 2LL * a >= a + d && a % 2 == 0LL) { return 1; } } b -= ((b - a - 1) / (2LL * a)) * (2LL * a); if (F.count(make_pair(a, b))) { return F[make_pair(a, b)]; } if (calc(b % a, a) == 2) { return F[make_pair(a, b)] = 1; } if (calc(b - a, a) == 2) { return F[make_pair(a, b)] = 1; } return F[make_pair(a, b)] = 2; } map<pair<int, int>, int> M; int triv(int a, int b) { if (a > b) { swap(a, b); } if (a == 0 || b == 0) { return 2; } if (b % a == 0) { return 1; } if (M.count(make_pair(a, b))) { return M[make_pair(a, b)]; } if (triv(a, b % a) == 2) { return M[make_pair(a, b)] = 1; } long long value = a; while ((long long)(b) >= value) { if (triv(b - value, a) == 2) { return M[make_pair(a, b)] = 1; } value *= a; } return M[make_pair(a, b)] = 2; } int main() { int t; cin >> t; for (int i = 0; i < t; ++i) { long long a, b; cin >> a >> b; int res = calc(a, b); if (res == 1) { printf("First\n"); } else { printf("Second\n"); } F.clear(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100005; bool f(long long a, long long b) { if (!a) return 0; return !(f(b % a, a) && (b / a % (a + 1) % 2)); } int main() { int t; scanf("%d", &t); while (t--) { long long a, b; scanf("%I64d%I64d", &a, &b); if (a > b) a ^= b, b ^= a, a ^= b; puts(f(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> bool win(long long a, long long b) { if (a > b) { return win(b, a); } if (a == 0) { return false; } if (!win(b % a, a)) { return true; } int res = (b / a - 1) % (a + 1); return (res & 1) || res == a; } int main() { int taskNumber; scanf("%d", &taskNumber); for (int taskIdx = 0; taskIdx < taskNumber; taskIdx++) { long long a, b; scanf("%I64d%I64d", &a, &b); puts(win(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; bool fwin(long long a, long long b) { if (a == 0 || b == 0) return false; if (a < b) swap(a, b); if (a % b == 0) return true; if (!fwin(b, a % b)) return true; long long k = a / b % (b + 1); return !(k & 1); } int main() { int t; long long a, b; scanf("%d", &t); while (t--) { scanf("%I64d %I64d", &a, &b); puts(fwin(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:255000000") bool firstout = 1; template <class T> T &minn(T &a, T b) { if (b < a) a = b; return a; } template <class T> T &maxx(T &a, T b) { if (a < b) a = b; return a; } int &madd(int &a, int b) { a += b; if (a >= 1000000009) a -= 1000000009; return a; } int &msub(int &a, int b) { a -= b; if (a < 0) a += 1000000009; return a; } int &mmult(int &a, int b) { return a = (long long)a * b % 1000000009; } int mdiv(long long a, long long b, long long m) { a = (a % m + m) % m; b = (b % m + m) % m; if (a % b == 0) return a / b; return (a + m * mdiv(-a, m, b)) / b; } int n, m; int A[1012]; bool fnd(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return 0; bool res = fnd(b % a, a); if (!res) return 1; b = b / a; b %= a + 1; return (b & 1) == 0; } int main() { int i, j, k; char c; long long a, b, d; int ts; int tss; scanf( "%" "d", &(tss)); for (ts = (1); ts < (tss + 1); ++ts) { scanf( "%" "I64d", &(a)); scanf( "%" "I64d", &(b)); int res = fnd(a, b); if (res) printf( "%" "s", ("First")); else printf( "%" "s", ("Second")); printf("\n"), firstout = 1; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; bool canWin(long long a, long long b) { if (a > b) return canWin(b, a); if (a == 0) return 0; if (canWin(b % a, a) == 0) return 1; long long i = b / a - 1; long long k = i % (a + 1); if ((k & 1) or k == a) return 1; return 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T--) { long long a, b; cin >> a >> b; if (canWin(a, b)) cout << "First\n"; else cout << "Second\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = -1; bool game(long long a, long long t) { t = t % (a + 1); return (t == a) || (t % 2 == 1); } bool win(long long a, long long b) { if (!a) return false; if (!win(b % a, a)) return true; return game(a, (b - (b % a + a)) / a); } int main() { int t; scanf("%d", &t); for (int cs = (0); cs < (int)(t); cs++) { long long a, b; scanf("%lld %lld", &a, &b); if (a > b) swap(a, b); cout << (win(a, b) ? "First" : "Second") << endl; } return 0; }
#include <bits/stdc++.h> template <typename T> bool ckmax(T &x, T y) { return x < y ? x = y, true : false; } template <typename T> bool ckmin(T &x, T y) { return x > y ? x = y, true : false; } using namespace std; const long long inf = 0x7f7f7f7f7f7f7f3f; const double Pi = acos(-1); const long long mod = 1e9 + 81; const double eps = 1e-6; inline long long fpow(long long a, long long b = mod - 2, long long p = mod) { a %= p; long long res = 1; while (b) { if (b & 1) res = 1ll * res * a % p; a = 1ll * a * a % p; b >>= 1; } return res; } inline long long read() { char c = getchar(); long long x = 0; bool f = 0; for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45); for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -x; return x; } inline void write(long long x) { if (x < 0) { putchar('-'); write(-x); return; } if (x >= 10) write(x / 10); putchar(x % 10 + '0'); } inline void writesp(long long x) { write(x), putchar(' '); } inline void writeln(long long x) { write(x); putchar('\n'); } long long solve(long long a, long long b) { if (!a) return 0; if (!solve(b % a, a)) return 1; long long g = ((b / a) - 1) % (a + 1); return g == a || g & 1; } signed main() { long long a, b; for (long long _ = read(); _--;) { a = read(), b = read(); if (a > b) swap(a, b); puts(solve(a, b) ? "First" : "Second"); } }
#include <bits/stdc++.h> using namespace std; bool winable(long long a, long long b) { long long ps; if (b % 2 == 0) ps = b + 1; else ps = 2; long long q = a / b; return ((q % ps) % 2) == 0; } bool solve(long long a, long long b) { vector<pair<long long, long long> > st; while (b > 0) { st.push_back(make_pair(a, b)); long long t = b; b = a % b; a = t; } reverse(st.begin(), st.end()); bool state = false; for (int i = 0; i < st.size(); ++i) { if (!state) { state = true; continue; } if (winable(st[i].first, st[i].second)) continue; state = false; } return state; } int main() { int t; cin >> t; for (int i = 0; i < t; ++i) { long long a, b; cin >> a >> b; if (a < b) { long long t = a; a = b; b = t; } cout << (solve(a, b) ? "First" : "Second") << endl; } return 0; }
#include <bits/stdc++.h> int main() { std::function<bool(long long int, long long int)> do_first_player_win = [&do_first_player_win](long long int a, long long int b) { assert(a <= b); if (a == 0) return false; else if (a == 1) return true; long long int modulo = b % a; if (do_first_player_win(modulo, a)) { if (a & 1) return (((b - modulo) / a) & 1) == 0; else { long long int m = ((b - modulo) / a) % (a + 1); return (m & 1) == 0; } } else return true; }; int t; for (std::scanf("%d", &t); t; t--) { long long int a, b; scanf("%lld %lld", &a, &b); if (a > b) std::swap(a, b); printf(do_first_player_win(a, b) ? "First\n" : "Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; inline bool dfs(long long a, long long b) { if (a == 0 || b == 0) return 0; if (a > b) swap(a, b); long long z = b % a; if (!dfs(a, z)) return 1; if ((b / a) % (a + 1) % 2 == 0) return 1; else return 0; } signed main() { ios::sync_with_stdio(false); long long cases; cin >> cases; for (long long i = 1; i <= cases; i++) { long long x, y; cin >> x >> y; if (dfs(x, y)) { cout << "First" << endl; } else cout << "Second" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int cond = 1; const int M = 100013; int t[M]; int rozwiaz(long long n, long long a) { return (n % (a + 1) % 2) ? 0 : 1; } int licz(long long a, long long b) { if (a > b) return licz(b, a); if (!a) return 0; int cc = licz(b % a, a); if (!cc) return 1; return rozwiaz(b / a, a); } int main() { int tt; cin >> tt; while (tt--) { long long a, b; cin >> a >> b; if (licz(a, b)) puts("First"); else puts("Second"); } return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16777216") using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); bool get(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return false; if (!get(b % a, a)) return true; if (a % 2 == 1) { return b / a % 2 != 1; } else { return b / a % (a + 1) % 2 != 1; } } int main() { int T; cin >> T; while (T--) { long long a, b; cin >> a >> b; puts(get(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b, vector<pair<long long, long long>> &v) { v.push_back({a, b}); if (a == 0) { return 0; } if (b == 0) { return 0; } if (a > b) { return 1 + gcd(a % b, b, v); } else { return 1 + gcd(a, b % a, v); } } vector<long long> basear(long long base, long long n) { if (base == 1) { return {0, n}; } vector<long long> ans; while (n > 0) { ans.push_back(n % base); n /= base; } return ans; } int main() { cin.tie(0); cin.sync_with_stdio(0); long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; vector<pair<long long, long long>> v1; long long r = gcd(a, b, v1); reverse(v1.begin(), v1.end()); vector<long long> dp(r + 1, 0); dp[1] = 1; for (long long i = 2; i < r + 1; i++) { if (dp[i - 1] == 0) { dp[i] = 1; } else { long long p = v1[i].first; long long p1 = v1[i].second; if (p > p1) { swap(p, p1); } vector<long long> v = basear(p, p1); long long count = 0; long long pow = 1; for (long long i = 1; i < v.size(); i++) { count += pow * v[i]; pow *= p; } if ((count) % (p + 1) % 2 == 0) { dp[i] = 1; } else { dp[i] = 0; } } } if (dp[r]) { cout << "First" << "\n"; } else { cout << "Second" << "\n"; } } }
#include <bits/stdc++.h> using namespace std; long long a, b; bool init(long long x, long long y) { if (x < y) return init(y, x); else { if (y == 0) return false; if (!init(x % y, y)) return true; long long tmp = x / y; if (tmp % (y + 1) % 2) return false; else return true; } } int main() { int t; scanf("%d", &t); while (t-- > 0) { scanf("%I64d%I64d", &a, &b); if (init(a, b)) puts("First"); else puts("Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; bool check(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return 0; if (!check(b, a % b)) return 1; a /= b; if ((b & 1) == 1) return (a & 1) == 0; a %= (b + 1); if ((a & 1) == 0) return 1; return 0; } int main() { int T; scanf("%d", &T); while (T--) { long long a, b; scanf("%I64d%I64d", &a, &b); check(a, b) ? puts("First") : puts("Second"); } return 0; };
#include <bits/stdc++.h> const int inf = 1039074182; using namespace std; long long a, b; bool dfs(long long a, long long b) { if (a >= b) swap(a, b); if (a == 0) return false; bool temp = dfs(a, b % a); if (temp == false) return true; long long t = (b - (b % a)); t /= a; if ((a & 2) == 1) { return (t % 2 == 0); } else { return ((t % (a + 1)) % 2 == 0); } } void solve() { if (dfs(a, b)) printf("First\n"); else printf("Second\n"); } int main() { int T; cin >> T; while (T--) { scanf("%I64d%I64d", &a, &b); solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const int inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; int dfs(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return 0; if (b % a == 0 || !dfs(b % a, a) || (b / a) % (a + 1) % 2 == 0) return 1; return 0; } int main() { int t; scanf("%d", &t); while (t--) { long long a, b; scanf("%I64d%I64d", &a, &b); if (dfs(a, b)) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7; bool dfs(long long a, long long b) { if (a > b) swap(a, b); if (!a) return false; if (b % a == 0 || !dfs(b % a, a) || (b / a) % (a + 1) % 2 == 0) return true; return false; } int main() { ios_base::sync_with_stdio(0); int t; cin >> t; while (t--) { long long a, b; cin >> a >> b; cout << (dfs(a, b) ? "First" : "Second") << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; const string Fi = "First\n", Se = "Second\n"; bool solve(long long a, long long b) { if (a == 0 || b == 0) return false; if (a > b) swap(a, b); if (!solve(b % a, a)) return true; long long x = b / a; if (a & 1) return (x ^ 1) & 1; return ((x % (a + 1)) ^ 1) & 1; } int main() { ios::sync_with_stdio(false); int T; cin >> T; while (T-- > 0) { long long a, b; cin >> a >> b; if (solve(a, b)) cout << Fi; else cout << Se; } }
#include <bits/stdc++.h> using namespace std; bool debug = false; bool dfs(long long a, long long b) { if (b < a) { swap(a, b); } if (a == 0) { return false; } bool mod = dfs(a, b % a); if (!mod) { return true; } long long t = b / a; return t % (a + 1) % 2 == 0; } int main(int argc, char* argv[]) { int t; cin >> t; while (t--) { long long a, b; cin >> a >> b; cout << (dfs(a, b) ? "First" : "Second") << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; bool solve(ll a, ll b) { if (a > b) return solve(b, a); if (a == 0) return false; if (!solve(b % a, a)) return true; return ((b / a) % (a + 1)) & 1 ^ 1; } int main() { ios ::sync_with_stdio(false); int t; cin >> t; while (t--) { ll a, b; cin >> a >> b; cout << (solve(a, b) ? "First" : "Second") << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; bool g(long long base, long long n) { if (base & 1) { long long tmp = 0; while (n) { tmp += n % base; n /= base; } return tmp % 2 == 0; } else { return (n % (base + 1)) % 2 == 0; } } bool win(long long mi, long long ma) { if (!mi) return 0; if (!win(ma % mi, mi)) return 1; return g(mi, ma / mi); } int main() { int i, j, k, n, t; long long a, b; scanf("%d", &t); while (t--) { cin >> a >> b; if (win(min(a, b), max(a, b))) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> bool dfs(int64_t a, int64_t b) { if (a == 0) { return true; } if (dfs(b % a, a)) { return false; } if (a % 2 == 1) { return (b / a) % 2; } return (b / a) % (a + 1) % 2; } int main() { long t; scanf("%ld\n", &t); while (t--) { int64_t a, b; scanf("%lld %lld\n", &a, &b); if (a > b) { int64_t c = a; a = b; b = c; } std::cout << (dfs(a, b) ? "Second" : "First") << std::endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(0); int n; cin >> n; for (int i = 0; i < n; ++i) solve(); } char gcd(long long a, long long b) { if (!b) return 0; char w = gcd(b, a % b); if (!w) return 1; long long q = a / b; if (b % 2) return (char)(q % 2 == 0); long long e = q % (b + 1); return (char)(e % 2 == 0); } void solve() { long long a, b; cin >> a >> b; if (a < b) swap(a, b); char res = gcd(a, b); if (res) cout << "First\n"; else cout << "Second\n"; }
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> r; int dp[1001]; void go(long long x, long long y, vector<pair<long long, long long>> &r) { r.clear(); while (x) { r.push_back(make_pair(x, y)); y %= x; swap(x, y); } r.push_back(make_pair(x, y)); return; } bool ok(long long b, long long a) { b = b / a - 1; return (b % (a + 1) % 2 == 1 || (b + 1) % (a + 1) == 0); } int main() { int tes; cin >> tes; for (int ii = 1; ii <= tes; ++ii) { long long x, y; cin >> x >> y; if (x > y) swap(x, y); go(x, y, r); reverse(r.begin(), r.end()); dp[0] = 0; for (int i = 1; i <= (int)(r).size() - 1; ++i) { if (dp[i - 1] == 0) dp[i] = 1; else { if (ok(r[i].second, r[i].first)) dp[i] = 1; else dp[i] = 0; } } if (dp[(int)(r).size() - 1]) cout << "First" << endl; else cout << "Second" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; bool Solve(long long a, long long b) { if (b == 0) { return false; } if (Solve(b, a % b)) { long long x = a / b; if (x % (b + 1) & 1) { return false; } else { return true; } } else { return true; } } int main(void) { int t; scanf("%d", &t); while (t--) { long long a, b; scanf("%lld%lld", &a, &b); if (a < b) swap(a, b); puts(Solve(a, b) ? "First" : "Second"); } return 0; }
#include <bits/stdc++.h> using namespace std; static long long int a[100005]; static long long int p[100005]; int ac; void GCD(long long int A, long long int B) { ac = 0; long long int C; while (B) { C = A % B; a[ac] = (A - C) / B; p[ac] = B; ac++; A = B; B = C; } } int main() { int T, iT; scanf("%d", &T); for (iT = 0; iT < T; iT++) { long long int X, Y, Z; scanf("%I64i %I64i", &X, &Y); if (X < Y) { Z = X; X = Y; Y = Z; } GCD(X, Y); int pos = 0; int i; for (i = ac - 1; i >= 0; i--) { if (pos == 0) pos = 1; else { long long int P = p[i] + 1LL; long long int temp = a[i] % P; if (temp % 2) pos = 0; else pos = 1; } } if (pos) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const char road[1000] = "C:\\data\\"; char roadnum[1000] = ""; char roadin[1000] = ""; char roadout[1000] = ""; void writeIntoFile(char num[]) { strcpy(roadnum, num); strcpy(roadin, road); strcat(roadin, roadnum); strcat(roadin, "."); strcpy(roadout, roadin); strcat(roadin, "in"); strcat(roadout, "out"); freopen(roadin, "r", stdin); freopen(roadout, "w", stdout); } void solve(); void solveM() { char ch[50]; for (int i = 1; i <= 30; i++) { sprintf(ch, "%d", i); writeIntoFile(ch); solve(); } } const long long M = 1e18; const long long MT = 1e4; bool isFirst(long long a, long long b) { if (a > b) swap(a, b); if (a == 0) return false; if (!isFirst(b % a, a)) return true; return ((b / a) % (a + 1)) % 2 == 0; } void solve() { long long a, b; int T; int ioflag = -1; ioflag = scanf("%d", &T); assert(ioflag == 1); assert(1 <= T && T <= MT); while (T--) { ioflag = scanf("%lld%lld", &a, &b); assert(ioflag == 2); assert(0 <= a && a <= M); assert(0 <= b && b <= M); if (isFirst(a, b)) { puts("First"); } else { puts("Second"); } } } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b; int t; bool win(long long a, long long b) { if (a == 0 || b == 0) return 0; if (a > b) swap(a, b); if (!win(a, b % a)) return 1; return ((b / a) % (a + 1)) % 2 == 0; } int main() { scanf("%d", &t); while (t--) { scanf("%I64d%I64d", &a, &b); if (win(a, b)) printf("First\n"); else printf("Second\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { return a > b ? a : b; } long long min(long long a, long long b) { return a < b ? a : b; } int dfs(long long ma, long long mi) { long long mod = ma % mi; if (mod == 0) { return 1; } if (dfs(mi, mod)) { return (ma / mi % (mi + 1) + 1) % 2; } else { return 1; } } int main() { int n; scanf("%d", &n); while (n--) { long long a, b; scanf("%I64d%I64d", &a, &b); long long ma = max(a, b), mi = min(a, b); if (mi == 0) printf("Second\n"); else { if (dfs(ma, mi)) printf("First\n"); else printf("Second\n"); } } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; const int MAXN = 100000007; const int MOD = 1e9 + 7; const double eps = 1e-8; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long getSG(long long x, long long y) { if (x == 0 || y == 0) return 0; long long a = min(x, y); long long b = max(x, y); if (getSG(b % a, a)) { b /= a; return !((b % (a + 1)) & 1); } return 1; } int main() { long long a, b; int T; scanf("%d", &T); while (T--) { scanf("%lld%lld", &a, &b); if (getSG(a, b) == 0) printf("Second\n"); else printf("First\n"); } }
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T& num) { num = 0; bool f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = 0; ch = getchar(); } while (ch >= '0' && ch <= '9') { num = num * 10 + ch - '0'; ch = getchar(); } num = f ? num : -num; } template <class T> inline void write(T x, char ch) { int s[100]; if (x == 0) { putchar('0'); putchar(ch); return; } if (x < 0) { putchar('-'); x = -x; } int num = 0; while (x) { s[num++] = (x % 10); x = x / 10; } for (int i = (num - 1); i >= (0); i--) putchar(s[i] + '0'); putchar(ch); } const double pi = acos(-1); const double eps = 1e-8; int main() { long long ans = 100000000000000; long long A[4], ord[4]; for (int i = (1); i <= (3); i++) { read(A[i]); ord[i] = i; } do { long long a = A[ord[1]], b = A[ord[2]], c = A[ord[3]]; if (b < c) swap(b, c); long long res = c; a += c, b -= c; res += (b / 2) * 2; if (b & 1) res += a; ans = min(ans, res); } while (next_permutation(ord + 1, ord + 4)); write(ans, '\n'); }
#include <bits/stdc++.h> using namespace std; long long a[3]; int main() { long long ans; while (scanf("%d%d%d", &a[0], &a[1], &a[2]) != EOF) { sort(a, a + 3); ans = a[2]; if ((a[0] + a[1]) % 2 == 0) { ans = min(ans, a[1]); } if ((a[1] + a[2]) % 2 == 0) { ans = min(ans, a[2]); } if ((a[0] + a[2]) % 2 == 0) { ans = min(ans, a[2]); } cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; long long min(long long x, long long y) { return x < y ? x : y; } int main() { long long c[3], f = 0; cin >> c[0] >> c[1] >> c[2]; long long mini = (long long)pow(2, 50), flag = 1; for (int i = 0, _ = 3; i < _; i++) for (int j = i + 1, _ = 3; j < _; j++) { if (c[i] % 2 == c[j] % 2) { mini = min(mini, max(c[i], c[j])); flag = 0; } } if (flag) cout << -1; else cout << mini; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e9 + 5; int main() { long long a, b, c; long long answer; cin >> a >> b >> c; if (a > b) swap(a, b); if (b > c) swap(b, c); if (a > b) swap(a, b); if (c % 2 == b % 2) answer = c; if (c % 2 == a % 2) answer = c; if (b % 2 == a % 2) answer = b; cout << answer << '\n'; }
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 10, P = 1000000007; int main() { unsigned a[3]; for (int i = 0; i < 3; i++) scanf("%u", a + i); sort(a, a + 3); long long s = 0; for (int i = 0; i < 3; i++) s += a[i]; long long ans = -1; for (int i = 0; i < 3; i++) { unsigned mn = 1u << 31, mx = 0; for (int j = 0; j < 3; j++) if (j != i) { mn = min(mn, a[j]); mx = max(mx, a[j]); } long long tmp = a[i]; tmp += mn; mx -= mn; if (mx & 1) continue; ans = max(ans, tmp); } if (ans >= 0) ans = s - ans; printf("%I64d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int inf = 0x7f7f7f7f; const int mod = 1000000007; long long a[N]; int main() { cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if ((a[1] - a[0]) % 2) cout << a[2] << endl; else cout << a[1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long INFLL = 1012345678901234567LL; long long calc(long long a, long long b, long long c) { if (b > c) swap(b, c); a += b; c -= b; return (c & 1) ? INFLL : b + c; } long long a, b, c; int main() { scanf("%I64d%I64d%I64d", &a, &b, &c); long long res = min(min(calc(a, b, c), calc(b, a, c)), calc(c, a, b)); printf("%I64d\n", res == INFLL ? a + b + c - 1 : res); return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b, c; long long res; int main() { cin >> a >> b >> c; res = a + b + c - 1ll; if (a % 2ll == b % 2ll) res = min(res, max(a, b)); if (a % 2ll == c % 2ll) res = min(res, max(a, c)); if (b % 2ll == c % 2ll) res = min(res, max(b, c)); cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 123456; long long a[3]; int main() { scanf("%I64d%I64d%I64d", &a[0], &a[1], &a[2]); sort(a, a + 3); printf("%I64d", (a[0] + a[1]) % 2 == 0 ? a[1] : a[2]); }
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; long long solve(long long a, long long b, long long c) { if (a % 2 != b % 2) return INF; long long res = 0; if (a > b) swap(a, b); res += a; b -= a; a -= a; res += b; return res; } int main() { vector<long long> v(3); while (cin >> v[0] >> v[1] >> v[2]) { long long ans = INF; sort((v).begin(), (v).end()); do { ans = min(ans, solve(v[0], v[1], v[2])); } while (next_permutation((v).begin(), (v).end())); cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; long long a[3]; int main() { int i, j; while (cin >> a[0] >> a[1] >> a[2]) { int cnt = 0; sort(a, a + 3); if ((a[1] - a[0]) % 2 == 0) cout << a[1] << endl; else cout << a[2] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b, c; long long getans(long long a, long long b, long long c) { if ((a - b) % 2) return a + b + c; long long x, y, z = max(0ll, (a - b) / 2); y = (2 * z + b - a) / 2; x = a - z + y; return a + b + c - max(0ll, (c - y - z + x)); } int main() { scanf("%I64d %I64d %I64d", &a, &b, &c); long long t1 = getans(a, b, c), t2 = getans(b, c, a), t3 = getans(c, a, b); long long ans = min(min(t1, t2), t3); if (ans == a + b + c) ans = -1; printf("%I64d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long a[3]; int main() { for (int i = 0; i < 3; i++) scanf("%lld", &a[i]); sort(a, a + 3); if ((a[1] - a[0]) % 2 == 0) printf("%lld\n", a[1]); else printf("%lld\n", a[2]); return 0; }
#include <bits/stdc++.h> using namespace std; long long check(long long a, long long b, long long c) { long long z = min(b, c); a += z; b -= z; c -= z; if (b == 0) b = c; if (b % 2 == 1) return 1; return a; } void lemon() { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); long long max = check(a, b, c); if (check(b, a, c) > max) max = check(b, a, c); if (check(c, a, b) > max) max = check(c, a, b); printf("%I64d\n", a + b + c - max); } int main() { lemon(); return 0; }
#include <bits/stdc++.h> int main() { static long long int a, b, c, x, y, z; scanf("%I64d%I64d%I64d", &a, &b, &c); x = (a > b && a > c) ? a : b > c ? b : c; y = (a < b && a < c) ? a : b < c ? b : c; z = a + b + c - x - y; if ((z - y) % 2) printf("%I64d\n", x); else printf("%I64d\n", z); return 0; }
#include <bits/stdc++.h> using namespace std; long long a[3], Answer = 1e18, tmp; int main() { cin >> a[0] >> a[1] >> a[2]; tmp = abs(a[0] - a[1]); if (tmp % 2 == 0) Answer = min(Answer, tmp / 2 + (a[0] + a[1]) / 2); tmp = abs(a[0] - a[2]); if (tmp % 2 == 0) Answer = min(Answer, tmp / 2 + (a[0] + a[2]) / 2); tmp = abs(a[2] - a[1]); if (tmp % 2 == 0) Answer = min(Answer, tmp / 2 + (a[2] + a[1]) / 2); cout << Answer << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> T MAX(T a, T b) { return a > b ? a : b; } template <class T> T MIN(T a, T b) { return a < b ? a : b; } template <class T1> void __(T1 p) { cout << p << endl; } template <class T1> void deb(T1 p) { cout << "Debugging: " << p << endl; } template <class T1, class T2> void deb(T1 p, T2 q) { cout << "Debugging: " << p << "\t" << q << endl; } template <class T1, class T2, class T3> void deb(T1 p, T2 q, T3 r) { cout << "Debugging: " << p << "\t " << q << "\t " << r << endl; } template <class T1, class T2, class T3, class T4> void deb(T1 p, T2 q, T3 r, T4 s) { cout << "Debugging: " << p << "\t " << q << "\t " << r << "\t " << s << endl; } long long int POOW(long long b, long long p) { if (p == 0) return 1; return b * POOW(b, p - 1); } const int first[] = {0, 0, 1, -1, -1, 1, -1, 1}; const int second[] = {1, -1, 0, 0, 1, 1, -1, -1}; const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2}; const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1}; long long HAHAHA(long long a, long long b, long long c) { long long p = max(a, max(b, c)); long long r = min(a, min(b, c)); long long q = a + b + c - p - r; if ((q - r) % 2 == 0) return q; return p; } int main() { ios_base::sync_with_stdio(false); long long i, t, j, k, l, keis(0), c, d, x, y, a, b; while (cin >> a >> b >> c) { __(HAHAHA(a, b, c)); } return 0; }
#include <bits/stdc++.h> using namespace std; long long p[5]; int main() { for (int i = 0; i < 3; i++) { scanf("%I64d", &p[i]); } sort(p, p + 3); if ((p[1] - p[0]) % 2 == 0) printf("%I64d\n", p[1]); else printf("%I64d\n", p[2]); return 0; }
#include <bits/stdc++.h> using namespace std; long long ans; vector<long long> v; int main() { ios_base::sync_with_stdio(0); for (int i = 0; i < 3; i++) { long long q; cin >> q; v.push_back(q); } ans = v[0] + v[1] + v[2] - 1; for (int i = 0; i < 3; i++) for (int j = i + 1; j < 3; j++) { if ((v[i] - v[j]) % 2 == 0) ans = min(ans, max(v[i], v[j])); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); if ((a & 1) == (b & 1) && (a & 1) == (c & 1)) { long long tmp; if (c >= a && c >= b) { tmp = max(a, b); } else if (b >= a && b >= c) { tmp = max(a, c); } else if (a >= b && a >= c) { tmp = max(b, c); } printf("%I64d\n", tmp); return 0; } if ((a & 1) == (b & 1)) { long long tmp = max(a, b); printf("%I64d\n", tmp); return 0; } if ((a & 1) == (c & 1)) { long long tmp = max(a, c); printf("%I64d\n", tmp); return 0; } if ((c & 1) == (b & 1)) { long long tmp = max(c, b); printf("%I64d\n", tmp); return 0; } }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); long long mini = 10000000000000000LL; for (int p = 0; p < 3; p++) { if ((a + b) % 2 != 0) { long long t = a; a = b; b = c; c = t; continue; } long long k = (a + b) / 2; mini = min(mini, k + abs(a - k)); long long t = a; a = b; b = c; c = t; } printf("%I64d\n", mini); }
#include <bits/stdc++.h> using namespace std; vector<long long> v; int main() { long long i, j, n, m, t, p, cas = 1; while (scanf("%I64d %I64d %I64d", &n, &m, &p) == 3) { v.push_back(n); v.push_back(m); v.push_back(p); sort(v.begin(), v.end()); if ((v[0] + v[1]) % 2 == 0) printf("%I64d\n", v[1]); else printf("%I64d\n", v[2]); v.clear(); } return 0; }
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base ::sync_with_stdio(false); vector<long long> a(3); for (auto& i : a) { cin >> i; } sort(a.begin(), a.end()); if (((a[1] - a[0]) & 1) == 0) { cout << a[1]; } else { cout << a[2]; } }
#include <bits/stdc++.h> using namespace std; void sch(long long &a, long long &b) { long long aux; aux = a; a = b; b = aux; } long long mini(long long a, long long b) { if (a <= b) return a; return b; } long long sol(long long a, long long b) { if ((a + b) % 2 != 0) return 10000000000LL; if (a > b) sch(a, b); return b; } long long a, b, c; long long rez; int main() { cin >> a >> b >> c; rez = 10000000000LL; rez = mini(rez, sol(a, b)); rez = mini(rez, sol(b, c)); rez = mini(rez, sol(a, c)); cout << rez; return 0; }
#include <bits/stdc++.h> using namespace std; long long c[3]; int main() { for (int k = 0; k < 3; k++) cin >> c[k]; sort(c, c + 3); if ((c[1] - c[0]) % 2 == 0) cout << c[1] << endl; else cout << c[2] << endl; return 0; }