D - Степени двойки
unknown
c_cpp
2 years ago
398 B
17
Indexable
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int p = 1, k = 0; while (p * 2 <= n) { p *= 2; k++; } if (n == 2) { cout << 0; } while (p > 1) { if (k % 2 == 0) { cout << p << " "; } k--; p /= 2; } return 0; }
Editor is loading...
Leave a Comment