結果

問題 No.1871 divisXor
ユーザー cologne
提出日時 2022-03-11 21:54:04
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 2,863 ms
コンパイル使用メモリ 248,540 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 12:56:17
合計ジャッジ時間 5,390 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    long long N; cin >> N;
    if(N == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<long long> ans;
    for(int K = 50; K>=0; --K)
    {
        if(N&(1LL<<K))
        {
            ans.push_back(1LL<<K);
            N ^= (1LL<<(K+1))-1;
        }
    }
    cout << ans.size() << endl;
    for(long long x: ans) cout << x << " ";
    cout << endl;
}
0