結果

問題 No.3088 XOR = SUM
ユーザー umezo
提出日時 2025-04-04 22:16:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 10,883 ms
コンパイル使用メモリ 556,136 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-04-04 22:16:31
合計ジャッジ時間 26,390 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int t;
  cin>>t;
  while(t--){
    ll n;
    cin>>n;
    if(n<=2){
      cout<<0<<" "<<0<<'\n';
      continue;
    }

    ll m=n;
    ll cnt=0;
    while(m){
      cnt++;
      m/=2;
    }
    Bint a=((1ll)<<(cnt-1));
    Bint l=a*(n-a);
    Bint b=((1ll)<<(cnt-2));
    Bint r=b*(b-1);
    if(l>r) cout<<a<<" "<<n-a<<'\n';
    else cout<<b<<" "<<b-1<<'\n';
  }
    
  return 0;
}
0