結果

問題 No.1243 約数加算
ユーザー tyaro804tyaro804
提出日時 2020-10-02 22:44:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,814 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 171,268 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-17 22:30:19
合計ジャッジ時間 2,154 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end() //
#define rall(v) (v).rbegin(), (v).rend() //
#define FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
const int inf = 1 << 30;
const ll INF = 1LL << 60;
int main(){
int t;
cin >> t;
// random_device seed_gen;
// mt19937_64 engine(seed_gen());
while(t--){
ll a, b;
cin >> a >> b;
// a = engine() % (ll) 1e18+1;
// b = engine() % (ll) 1e18+1;
// if (a > b) continue;
VL ans;
while(2*a <= b){
ans.push_back(a);
a *= 2;
}
while(a != b){
if (a % 2 != 0){
a++;
ans.push_back(1);
continue;
}
ll num = 1, p = 1;
ll diff = b - a;
while(num <= diff){
if (a % num == 0){
p = num;
}
num *= 2;
}
a += p;
ans.push_back(p);
// if (sz(ans) > 120) break;
}
view(sz(ans));
rep(i,sz(ans)) printf("%lld%c", ans[i], i==sz(ans)-1?'\n':' ');
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0