-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
52 lines (50 loc) · 1.02 KB
/
C.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
long long power(long long x,long long y)
{
long long u=1;
for(long long i=0;i<y;i++)
u*=x;
return u;
}
int main()
{
fastio;
long long n,c=0,flag=0,i;
vector<long long> ans;
ans.push_back(0LL);
cin>>n;
long long m=n;
while(n!=0)
{
if(flag==1)
break;
if(n%2==1)
{
long long p=power(2,c);
long long x=ans.size();
for(i=0;i<x;i++)
{
long long tmp=p+ans[i];
if(tmp<=m/2)
ans.push_back(tmp);
else
{
flag=1;
break;
}
}
}
n/=2;
c++;
}
for(i=0;i<ans.size();i++)
cout<<ans[i]<<"\n";
for(i=ans.size()-1;i>=0;i--){
if(m-ans[i]!=ans[i])
cout<<m-ans[i]<<"\n";
}
return 0;
}