結果
問題 | No.1243 約数加算 |
ユーザー |
![]() |
提出日時 | 2023-03-03 07:07:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,071 bytes |
コンパイル時間 | 3,764 ms |
コンパイル使用メモリ | 251,468 KB |
最終ジャッジ日時 | 2025-02-11 01:19:17 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 1 WA * 8 |
ソースコード
#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 <=61; i++) { if (a%two[i]==0) { now=max(now,i); } } vector<ll>ans; while (two[now]<x) { ans.push_back(two[now]); x-=two[now]; now+=1; } for (ll i = 61; 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; } }