結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2023-03-03 07:10:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,226 bytes |
| コンパイル時間 | 4,728 ms |
| コンパイル使用メモリ | 252,164 KB |
| 最終ジャッジ日時 | 2025-02-11 01:19:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=double;
ld pie=3.14159265359;
ll mod=998244353;
long long inf=100000000000000001;
int main(){
ll t;
cin >> t;
vector<ll>two(62,1);
for (ll i = 1; i < two.size(); i++)
{
two[i]=two[i-1]*2;
}
for (ll o = 0; o < t; o++)
{
ll a,b;
cin >> a >> b;
ll x=b-a;
ll now=0;
for (ll i = 0; i <=60; i++)
{
if (a%two[i]==0)
{
now=max(now,i);
}
}
vector<ll>ans;
ll aa=a;
while (two[now]<x)
{
if (aa%two[now+1]==0)
{
now+=1;
continue;
}
ans.push_back(two[now]);
aa+=two[now];
x-=two[now];
now+=1;
}
for (ll i = 60; i >=0; i--)
{
if (two[i]&x)
{
ans.push_back(two[i]);
}
}
cout << ans.size() << endl;
for (ll i = 0; i < ans.size(); i++)
{
cout << ans[i]<< ' ';
}
cout << endl;
}
}
hiro71687k