結果

問題 No.1243 約数加算
ユーザー logxlogx
提出日時 2020-10-02 21:34:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,647 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 172,236 KB
実行使用メモリ 51,464 KB
最終ジャッジ日時 2023-09-23 04:18:43
合計ジャッジ時間 8,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int t;cin >> t;
    vector<vector<ll>> ans;
    rep(aaa,t){
        ll a,b;cin >> a >> b ;
        /*
        gcd(a,b)を足し続けると良さそう…?
        */
        vector<ll> out;
        while(a<b){
            out.push_back(__gcd(a,b));
            a+=__gcd(a,b);
        }
        out.push_back(out.size());
        ans.push_back(out);
    }
    rep(i,ans.size()){
        cout << ans[i][ans[i].size()-1] << endl;
        rep(j,ans[i].size()-1){
            cout << ans[i][j] << " \n"[j+2==(int)ans[i].size()];
        }
    }
}
0