結果
| 問題 | No.3088 XOR = SUM | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-04-04 21:37:30 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 411 ms / 2,000 ms | 
| コード長 | 1,712 bytes | 
| コンパイル時間 | 5,804 ms | 
| コンパイル使用メモリ | 307,176 KB | 
| 実行使用メモリ | 6,144 KB | 
| 最終ジャッジ日時 | 2025-04-04 21:40:00 | 
| 合計ジャッジ時間 | 24,496 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 22 | 
ソースコード
#pragma GCC optimize ("O3,inline,omit-frame-pointer,no-asynchronous-unwind-tables,fast-math")
#include <bits/stdc++.h>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 
int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll t; cin >> t;
    while(t--){
        ll n; cin >> n;
        ll x = 0, y = 0;
        {
            ll flg = 0;
            rrep(i,60,0){
                if((n>>i)&1){
                    if(flg) y += 1LL << i;
                    else{
                        x += 1LL << i;
                        flg = true;
                    }
                }
            }
        }
        {
            ll xx = 0, yy = 0;
            ll flg = 0, flg2 = 0;
            rrep(i,60,0){
                if(flg){
                    if(flg2) yy += 1LL << i;
                    else{
                        xx += 1LL << i;
                        flg2 = true;
                    }
                }
                else if((n>>i)&1)flg = true;
            }
            __int128_t num1 = (__int128_t) x*(__int128_t)y;
            __int128_t num2 = (__int128_t) xx*(__int128_t)yy;
            if(num1 < num2){
                x = xx;
                y = yy;
            }
        }
        cout << x << " " << y << endl;
    }
    return 0;
}
            
            
            
        