結果
問題 | No.1243 約数加算 |
ユーザー |
![]() |
提出日時 | 2020-10-03 04:29:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 1,892 ms |
コンパイル使用メモリ | 195,144 KB |
最終ジャッジ日時 | 2025-01-15 01:50:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:5: warning: ‘num’ may be used uninitialized [-Wmaybe-uninitialized] 26 | if(num==0){ | ^~ main.cpp:18:9: note: ‘num’ was declared here 18 | int num; | ^~~
ソースコード
#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> A;int num;for(int i=60;i>=0;i--){if(!(a&(1LL<<i)) && b&(1LL<<i)){num=i;break;}}if(num==0){a++;A.push_back(1);}while((a&(1LL<<num))==0){A.push_back(a&-a);a+=a&-a;}for(int i=60;i>=0;i--){if(!(a&(1LL<<i)) && b&(1LL<<i)){A.push_back(1LL<<i);a+=(1LL<<i);}}cout<<A.size()<<endl;rep(i,A.size()){if(i) cout<<" ";cout<<A[i];}cout<<endl;}return 0;}