結果

問題 No.1243 約数加算
ユーザー sonotarousonotarou
提出日時 2021-01-31 00:54:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 168,368 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 21:53:43
合計ジャッジ時間 2,367 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;   

vector<ll> solve(ll a, ll b){
    vector<ll> ret(1);
    for(int i=0;i<60;i++)if(a&(1LL<<i) && a+(1LL<<i)<=b) ret.push_back(1LL<<i), a+=1LL<<i, ret[0]++;
    for(int i=60;i>=0;i--)if(a+(1LL<<i)<=b) ret.push_back(1LL<<i), a+=1LL<<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