//ej jak ktos z znajomych patrzy na moj kod po zakonczeniu potyczek to mam dla ciebie informacje
//you just lost the game <3333
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n; cin>>n;
int cnt=0; int i=1;
while(cnt<n){
cnt+=__builtin_popcount(i);
i++;
}
i--;
vector<int> res;
while(i>0){
if(cnt-__builtin_popcount(i)>=n) cnt-=__builtin_popcount(i);
else res.push_back(i);
i--;
}
cout<<res.size()<<'\n';
for(auto i : res) cout<<i<<' ';
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | //ej jak ktos z znajomych patrzy na moj kod po zakonczeniu potyczek to mam dla ciebie informacje //you just lost the game <3333 #include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin>>n; int cnt=0; int i=1; while(cnt<n){ cnt+=__builtin_popcount(i); i++; } i--; vector<int> res; while(i>0){ if(cnt-__builtin_popcount(i)>=n) cnt-=__builtin_popcount(i); else res.push_back(i); i--; } cout<<res.size()<<'\n'; for(auto i : res) cout<<i<<' '; return 0; } |
English