結果
問題 |
No.1243 約数加算
|
ユーザー |
![]() |
提出日時 | 2020-10-04 18:34:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 1,436 ms |
コンパイル使用メモリ | 170,260 KB |
実行使用メモリ | 141,348 KB |
最終ジャッジ日時 | 2024-07-19 17:46:57 |
合計ジャッジ時間 | 7,101 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 1 TLE * 1 -- * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using Graph=vector<vector<int>>; #define MOD 1000000007 /* srand((unsigned int)time(NULL)); for(int i=0;i<10;i++){ cout<<rand()%6+1<<" "; } */ /* clock_t start,end; start=clock(); end=clock(); double t=(double)(end-start)/CLOCKS_PER_SEC; t<2.9; */ ll gcd(ll a,ll b){ ll tmp=a%b; while(tmp!=0){ a=b; b=tmp; tmp=a%b; } return b; } int main(){ int T; cin>>T; for(int i=0;i<T;i++){ ll A,B; cin>>A>>B; vector<ll> ans; while(2*A<=B){ ans.push_back(A); A+=A; } while(A<B){ ll x=gcd(A,B-A); A+=x; ans.push_back(x); } cout<<ans.size()<<'\n'; for(int j=0;j<ans.size();j++){ cout<<ans[j]<<" "; } cout<<'\n'; } }