結果
問題 |
No.1113 二つの整数 / Two Integers
|
ユーザー |
|
提出日時 | 2024-11-09 12:17:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 1,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 559 ms |
コンパイル使用メモリ | 67,020 KB |
最終ジャッジ日時 | 2025-02-25 03:17:44 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 |
ソースコード
#include <iostream> #include <cstdint> using namespace std; template<typename T1, typename T2> constexpr decltype((T1)1 % (T2)1) GCD(const T1 a, const T2 b) noexcept { decltype((T1)1 % (T2)1) x = a, y = b, z = 0; while (y != 0) z = x % y, x = y, y = z; return x; } template<typename T1, typename T2> constexpr bool is_squared(const T1 target, T2 l, T2 r) noexcept { while (l < r) { const T2 c = l + (r - l) / 2; const decltype((T1)1 * (T2)1) c_squared = static_cast<decltype((T1)1 * (T2)1)>(c) * c; if (c_squared < target) l = c + 1; else if (c_squared != target) r = c; else return true; } return false; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint64_t A, B; cin >> A >> B; if (is_squared(GCD(A, B), 1, 1'000'000'001)) cout << "Odd\n"; else cout << "Even\n"; return 0; }