結果

問題 No.1243 約数加算
ユーザー sonotarousonotarou
提出日時 2021-01-31 00:04:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 705 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 168,392 KB
実行使用メモリ 813,908 KB
最終ジャッジ日時 2023-09-10 21:05:30
合計ジャッジ時間 4,375 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

ll t,a,b,idx,l=1;   

vector<ll> solve(ll a, ll b){
    vector<ll> ret(1);
    while(l*2<b) l*=2, idx++;
    while(a!=l) ret.push_back(a&-a), a+=(a&-a), ret[0]++;
    for(ll i=idx-1;i>=0;i--)if(b & ll(1)<<i) ret.push_back(ll(1)<<i), ret[0]++;
    return ret;
}

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

   cin >> t;
   while(t--){
       cin >> a >> b;
       for(auto ans : solve(a,b)) cout << ans << endl;
    }
}
0