結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
ricoriser32
|
| 提出日時 | 2020-10-02 21:29:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,205 bytes |
| コンパイル時間 | 2,333 ms |
| コンパイル使用メモリ | 200,176 KB |
| 最終ジャッジ日時 | 2025-01-14 23:59:56 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 TLE * 5 |
ソースコード
//#include <atcoder/all>
//using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size())
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);
vector<ll> divisor(ll n) {
vector<ll> ret;
for(ll i = 1; i * i <= n; i++) {
if(n % i == 0) {
ret.push_back(i);
if(i * i != n) ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while(t--){
ll a,b; cin >> a >> b;
vector<ll> ans;
while(a<b){
auto div = divisor(a);
auto itr = upper_bound(ALL(div), b-a);
itr--;
ans.push_back(*itr);
a += *itr;
}
cout << SIZE(ans) << '\n';
for(auto v: ans) cout << v << " ";
cout << '\n';
}
return 0;
}
ricoriser32