Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef int64_t Int;
- int main() {
- ios_base::sync_with_stdio(false);
- //freopen("input.txt", "rt", stdin);
- Int need, diff; cin >> need >> diff;
- if (need <= 10000) {
- cout << need << endl;
- for (int i = 0; i < need; ++i) {
- cout << 1 + diff * i << " ";
- }
- return 0;
- }
- vector<Int> a;
- Int curr = 1;
- while (need > 0) {
- Int pow = 1;
- while ((Int(1) << (pow+1)) - 1 <= need) {
- ++pow;
- }
- need -= ((Int(1) << pow) - 1);
- for (Int i = 0; i < pow; ++i) {
- a.push_back(curr);
- }
- assert(curr < (Int)1e18L);
- curr += diff;
- }
- assert(a.size() <= (Int)1e4);
- cout << a.size() << endl;
- for (auto it : a) cout << it << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement