結果

問題 No.1243 約数加算
ユーザー tyaro804tyaro804
提出日時 2020-10-02 21:49:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,711 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 170,852 KB
実行使用メモリ 7,836 KB
最終ジャッジ日時 2023-09-23 04:42:11
合計ジャッジ時間 6,112 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;

vector<ll> enumerate_num(ll x){
    vector<ll> res;
    for(ll i = 1; i * i <= x; i++){
        if (x % i == 0){
            res.push_back(i);
            if (i * i != x) res.push_back(x / i);
        }
    }
    sort(all(res));
    return res;
}

int main(){
    int t;
    cin >> t;
    while(t--){
        ll a, b;
        cin >> a >> b;
        while(2*a <= b){
            cout << a << " ";
            a *= 2;
        }
        while(b != a){
            ll diff = b - a;
            auto res = enumerate_num(diff);
            int usei = 0;
            rep(i, sz(res)){
                if (a + res[i] <= b){
                    usei = i;
                    continue;
                }
                break;
            }
            a += res[usei];
            cout << res[usei] << " ";
        }
        cout << endl;
    }
    return 0;
}
0