結果
問題 | No.726 Tree Game |
ユーザー | Pachicobue |
提出日時 | 2018-08-24 21:45:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,211 bytes |
コンパイル時間 | 2,047 ms |
コンパイル使用メモリ | 194,268 KB |
最終ジャッジ日時 | 2025-01-06 12:32:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
//================================= // Created on: 2018/08/24 21:23:14 //================================= #include <bits/stdc++.h> #define show(x) std::cerr << #x << " = " << x << std::endl using ll = long long; using ull = unsigned long long; using ld = long double; constexpr ll MOD = 1000000007LL; template <typename T> constexpr T INF = std::numeric_limits<T>::max() / 10; std::mt19937 mt{std::random_device{}()}; int main() { ll Y, X; std::cin >> Y >> X; auto p = [](const ll n) { if (n == 1) { return false; } for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return true; }; if (p(Y) and p(X)) { return (std::cout << "Second" << std::endl), 0; } bool rev = false; if (p(Y)) { Y++, rev = true; } if (p(X)) { X++, rev = true; } auto rec = [&](auto&& self, const ll y, const ll x, const bool first) { if (p(y) or p(x)) { return std::cout << (not first ? "Second" : "First") << std::endl, (void)(0); } if (not p(y + 1)) { self(self, y + 1, x, not first); } else { self(self, y, x + 1, not first); } }; rec(rec, Y, X, not rev); return 0; }