結果

問題 No.3088 XOR = SUM
ユーザー rgnerdplayer
提出日時 2025-05-07 12:22:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 5,270 ms
コンパイル使用メモリ 272,948 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-07 12:22:41
合計ジャッジ時間 13,181 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    auto solve = [&]() {
        int n;
        cin >> n;

        if (n == 0) {
            cout << 0 << ' ' << 0 << '\n';
            return;
        }

        int x = 1 << __lg(n);

        i64 res1 = 1LL * x * (n - x);
        i64 res2 = 1LL * 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;
}
0