結果

問題 No.1243 約数加算
ユーザー mmn15277198mmn15277198
提出日時 2020-10-06 21:50:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
J_TLE  
(最初)
実行時間 -
コード長 832 bytes
コンパイル時間 864 ms
コンパイル使用メモリ 92,488 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 08:56:37
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(){
	int t;
	cin >> t;
	while(t--){
		ll a , b;
		cin >> a >> b;
		vector<ll> ans;
		int bit = 1;
		while((1LL << bit) <= b){
			if((a & (1LL << bit)) != 0 && (b & (1LL << bit)) == 0){
				a += (1LL << bit);
				ans.push_back(1LL << bit);
			}
			bit++;
		}
		
		while(bit >= 0){
			if((a & (1LL << bit)) == 0 && (b & (1LL << bit)) != 0){
				a += (1LL << bit);
				ans.push_back(1LL << bit);
			}
			bit--;
		}
		
		cout << ans.size() << endl;
		for(int i = 0; i < ans.size(); i++){
			cout << ans[i] << " ";
		}
		cout << endl;
		//cout << a << endl;
	}
	return 0;
}
0