結果
| 問題 | No.3088 XOR = SUM | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2025-04-08 15:21:54 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 120 ms / 2,000 ms | 
| コード長 | 669 bytes | 
| コンパイル時間 | 743 ms | 
| コンパイル使用メモリ | 56,696 KB | 
| 実行使用メモリ | 7,848 KB | 
| 最終ジャッジ日時 | 2025-04-08 15:22:12 | 
| 合計ジャッジ時間 | 16,498 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 22 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |   scanf("%d", &tn);
      |   ~~~~~^~~~~~~~~~~
main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 3088.cc:  No.3088 XOR = SUM - yukicoder
 */
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
/* constant */
/* typedef */
using ll = long long;
/* global variables */
/* subroutines */
/* main */
int main() {
  int tn;
  scanf("%d", &tn);
  while (tn--) {
    ll n;
    scanf("%lld", &n);
    if (n == 0) { puts("0 0"); continue; }
    
    ll msb = 1;
    while ((msb << 1) <= n) msb <<= 1;
    ll x = msb, y = n ^ msb;
    if (x > 1) {
      ll x0 = (x >> 1), y0 = x0 - 1;
      if (logl(x) + logl(y) < logl(x0) + logl(y0))
	x = x0, y = y0;
    }
    printf("%lld %lld\n", x, y);
  }
  return 0;
}
            
            
            
        