結果

問題 No.1243 約数加算
ユーザー furafura
提出日時 2020-10-03 18:28:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 200,224 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 05:34:34
合計ジャッジ時間 2,880 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

void solve(){
	lint a,b; scanf("%lld%lld",&a,&b);

	int d;
	for(d=60;d>=0;d--) if((a>>d&1)!=(b>>d&1)) break;
	assert(d!=-1);

	vector<lint> ans;
	rep(i,d) if(a>>i&1) {
		a+=1LL<<i;
		ans.emplace_back(1LL<<i);
	}
	for(int i=d-1;i>=0;i--) if((a>>i&1)!=(b>>i&1)) {
		ans.emplace_back(1LL<<i);
	}

	printf("%ld\n",ans.size());
	rep(i,ans.size()) printf("%lld%c",ans[i],i+1<ans.size()?' ':'\n');
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}
0