結果

問題 No.1243 約数加算
ユーザー umezoumezo
提出日時 2020-10-02 22:50:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 829 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 205,460 KB
実行使用メモリ 7,588 KB
最終ジャッジ日時 2023-09-24 22:21:22
合計ジャッジ時間 5,923 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int t;
  cin>>t;
  
  while(t--){
    ll a,b;
    cin>>a>>b;
    
    vector<ll> B;
    
    while(a<b){
      if(b-a>=a){
        B.push_back(a);
        a+=a;
        continue;
      }
      vector<ll> A;
      ll n=a;
      for(int i=1;i*i<=n;i++){
        if(n%i==0){
          A.push_back(i);
          if(i*i!=n) A.push_back(n/i);
          if(i>=b-a) break;
          if(n/i<=b-a) break;
        }
      }
      sort(ALL(A));
      auto itr=upper_bound(ALL(A),b-a);
      itr--;
      a+=*itr;
      B.push_back(*itr);
    }
    
    cout<<B.size()<<endl;
    rep(i,B.size()){
      if(i) cout<<" ";
      cout<<B[i];
    }
    cout<<endl;
  }
  
  return 0;
}
0