結果

問題 No.1243 約数加算
ユーザー mmn15277198mmn15277198
提出日時 2020-10-06 19:15:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 92,524 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 08:51:00
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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;

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