結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
IKyopro
|
| 提出日時 | 2020-10-02 21:33:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,091 bytes |
| コンパイル時間 | 2,547 ms |
| コンパイル使用メモリ | 197,008 KB |
| 最終ジャッジ日時 | 2025-01-15 00:03:33 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 2 RE * 2 MLE * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << (x) << endl;
void solve(){
ll A,B;
cin >> A >> B;
vec<ll> ans;
if(A==1){
ans.push_back(1);
A++;
}
vec<ll> p = {1,A};
while(p.back()<=B/A){
p.push_back(p.back()*A);
ans.push_back(A);
}
int n = p.size();
int id = n-1;
B -= A;
while(B){
while(B>=p[id]){
ans.push_back(p[id]);
B -= p[id];
}
id--;
}
int m = ans.size();
assert(m<=120);
cout << m << "\n";
for(int i=0;i<m;i++) cout << ans[i] << (i!=m-1? " ":"\n");
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int T;
cin >> T;
while(T--){
solve();
}
}
IKyopro