結果

問題 No.1243 約数加算
ユーザー risujirohrisujiroh
提出日時 2020-10-02 21:46:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,910 bytes
コンパイル時間 4,104 ms
コンパイル使用メモリ 374,792 KB
最終ジャッジ日時 2025-01-15 00:10:00
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt")
// #define NDEBUG
#include <bits/extc++.h>
#include <x86intrin.h>
struct rep {
struct iter {
int i;
constexpr void operator++() { ++i; }
constexpr int operator*() const { return i; }
friend constexpr bool operator!=(iter a, iter b) { return *a != *b; }
};
const int l, r;
constexpr rep(int _l, int _r) : l(std::min(_l, _r)), r(_r) {}
constexpr rep(int n) : rep(0, n) {}
constexpr iter begin() const { return {l}; }
constexpr iter end() const { return {r}; }
};
struct per {
struct iter {
int i;
constexpr void operator++() { --i; }
constexpr int operator*() const { return i; }
friend constexpr bool operator!=(iter a, iter b) { return *a != *b; }
};
const int l, r;
constexpr per(int _l, int _r) : l(std::min(_l, _r)), r(_r) {}
constexpr per(int n) : per(0, n) {}
constexpr iter begin() const { return {r - 1}; }
constexpr iter end() const { return {l - 1}; }
};
template <class T, class U>
constexpr bool chmin(T& a, U&& b) {
return b < a ? a = std::forward<U>(b), true : false;
}
template <class T, class U>
constexpr bool chmax(T& a, U&& b) {
return a < b ? a = std::forward<U>(b), true : false;
}
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int tt;
cin >> tt;
while (tt--) {
int64_t a, b;
cin >> a >> b;
int d = __lg(a ^ b);
if (a % (int64_t(1) << (d + 1)) == 0) d = __builtin_ctz(a);
vector<int64_t> ans;
for (int s : rep(d))
if (a >> s & 1) {
ans.push_back(int64_t(1) << s);
a += ans.back();
}
for (int s : per(d))
if (b >> s & 1) ans.push_back(int64_t(1) << s);
cout << size(ans) << '\n';
for (int i : rep(size(ans)))
cout << ans[i] << " \n"[i == int(size(ans)) - 1];
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0