結果
| 問題 | No.3088 XOR = SUM | 
| コンテスト | |
| ユーザー |  rgnerdplayer | 
| 提出日時 | 2025-05-07 12:23:28 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,377 bytes | 
| コンパイル時間 | 4,239 ms | 
| コンパイル使用メモリ | 278,664 KB | 
| 実行使用メモリ | 7,848 KB | 
| 最終ジャッジ日時 | 2025-05-07 12:23:40 | 
| 合計ジャッジ時間 | 11,820 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | WA * 22 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using i128 = __int128_t;
istream& operator>>(istream &is, i128 &n) {
    string s;
    cin >> s;
    bool neg = false;
    if (s[0] == '-') {
        neg = true;
        s = s.substr(1);
    }
    n = 0;
    for (auto ch : s) {
        n = n * 10 + ch - '0';
    }
    if (neg) {
        n = -n;
    }
    return is;
}
ostream& operator<<(ostream &os, i128 n) {
    if (n < 0) {
        os << '-';
        n = -n;
    }
    if (n == 0) {
        os << 0;
    } else {
        string s;
        while (n > 0) {
            s += '0' + n % 10;
            n /= 10;
        }
        reverse(s.begin(), s.end());
        os << s;
    }
    return os;
}
i128 gcd(i128 x, i128 y) {
    return y == 0 ? x : gcd(y, x % y);
}
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    auto solve = [&]() {
        i64 n;
        cin >> n;
        if (n == 0) {
            cout << 0 << ' ' << 0 << '\n';
            return;
        }
        int x = 1LL << __lg(n);
        i128 res1 = i128(x) * (n - x);
        i128 res2 = i128(x) / 2 * (x / 2 - 1);
        if (res1 > res2) {
            cout << x << ' ' << n - x << '\n';
        } else {
            cout << x / 2 << ' ' << x / 2 - 1 << '\n';
        }
    };
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
            
            
            
        