結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
totori_nyaa
|
| 提出日時 | 2020-10-02 21:55:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,258 bytes |
| コンパイル時間 | 2,053 ms |
| コンパイル使用メモリ | 194,984 KB |
| 最終ジャッジ日時 | 2025-01-15 00:14:19 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
ll dx[4]={0,1,-1,0};
ll dy[4]={1,0,0,-1};
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
int q; cin>>q;
while(q--){
ll a,b;
cin>>a>>b;
vector<ll> ans;
if(a%2){
ans.push_back(1);
a++;
}
ll now = 1;
ll dif = b - a;
while(dif>=1 && now<62){
if(dif>=(1LL<<(now-1)) && a%(1LL<<now)){
ans.push_back(1LL<<(now-1));
dif -= (1LL<<now-1);
a += (1LL<<(now-1));
}
now++;
}
now = 61;
while(dif){
if(dif & (1LL<<now)){
ans.push_back(1LL<<now);
a += (1LL<<now);
dif -= (1LL<<now);
}
now--;
}
cout << ans.size() << "\n";
for(int i=0;i<ans.size();i++){
if(i)cout << " ";
cout << ans[i];
}
cout << "\n";
}
}
totori_nyaa