D - Степени двойки
Anonymous
c_cpp
11/21/2023 6:20 AM
532 B
32
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