結果

問題 No.1450 nahco314's First Problem
ユーザー Mister
提出日時 2021-03-31 15:47:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 65,660 KB
最終ジャッジ日時 2025-01-20 01:58:01
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"
#include <iostream>

using namespace std;
using lint = long long;

void solve() {
    lint x;
    cin >> x;

    for (int b = 1; b <= 62; ++b) {
        auto y = (x ^ b);
        if (__builtin_popcountll(y) == b) {
            cout << y << "\n";
            return;
        }
    }

    cout << "-1\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0