結果

問題 No.3088 XOR = SUM
ユーザー applejam
提出日時 2025-04-04 22:50:49
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 1,413 bytes
コンパイル時間 3,498 ms
コンパイル使用メモリ 174,876 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-04-04 22:51:15
合計ジャッジ時間 22,089 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:16: warning: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
   48 |         if(bs[b-1] || bs[b-2]){
      |               ~^~
main.cpp:41:13: note: ‘b’ was declared here
   41 |         int b;
      |             ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vmi = vector<mint>;
using vvmi = vector<vmi>;
using vvvmi = vector<vvmi>;
#define all(a) (a).begin(), (a).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t; cin >> t;
    while(t--){
        ll n; cin >> n;
        bitset<64> bs(n);
        if(n <= 2){
            cout << (n+1)/2 << " 0" << endl;
            continue;
        }
        if(n <= 3){
            cout << (n+1)/2 << " 1" << endl;
            continue;
        }
        bitset<64> x, y;
        int b;
        drep(i, 64){
            if(bs[i]){
                b = i;
                break;
            }
        }
        if(bs[b-1] || bs[b-2]){
            x.set(b);
            drep(j, b)y[j] = bs[j];
        }else{
            x.set(b-1);
            drep(j, b-1)y[j] = 1;
        }

        cout << x.to_ullong() << " " << y.to_ullong() << endl;
    }

    return 0;
}
0