結果
| 問題 | No.3088 XOR = SUM |
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-04-04 22:59:46 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 2,000 ms |
| コード長 | 872 bytes |
| 記録 | |
| コンパイル時間 | 6,541 ms |
| コンパイル使用メモリ | 332,604 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-04 23:00:17 |
| 合計ジャッジ時間 | 19,157 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
ll n;
cin >> n;
if (n == 0) {
cout << "0 0\n";
continue;
}
ll a = 0, b = 0;
int p = 0;
rep(i, 0, 62) {
if (n & (1LL << i)) {
p = i;
}
}
ll m = 1LL << p;
a = m;
b = n ^ m;
if (p >= 1) {
ll na = 1LL << (p - 1);
ll nb = na - 1;
if ((__int128)a * b < (__int128)na * nb) {
a = na;
b = nb;
}
}
cout << a << ' ' << b << '\n';
}
}
SnowBeenDiding