結果

問題 No.3088 XOR = SUM
ユーザー zawakasu
提出日時 2025-04-04 21:49:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,019 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 103,708 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-04-04 21:50:01
合計ジャッジ時間 14,569 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
using i128 = __int128_t;
void solve(long long N) {
    long long mbit = 1;
    while (mbit <= N) mbit <<= 1;
    mbit >>= 1;
    i128 ans = (i128)mbit * (N - mbit);
    long long X = mbit, Y = (N - mbit);
    if (N >= 4) {
        mbit >>= 1;
        if (ans < (i128)mbit * ((mbit << 1) - 1 - mbit)) {
            X = mbit;
            Y = (mbit << 1) - 1 - mbit;
        }
    }
    std::cout << X << ' ' << Y << '\n';
}
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T;
    std::cin >> T;
    while (T--) {
        long long N;
        std::cin >> N;
        solve(N);
    }
}
0