Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
851 B
6
Indexable
Never
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int s(int n)
{
	int p=n;
	int y=0;
	int c=1;
	while(p>0)
	{
		y+=p%2*(c);
		c*=10;
		p/=2;
	}
	int r=0;
	while(y>0)
	{
		r+=y%10;
		y/=10;
	}
	return r%2;
}
int main()
{
	vector<int> n;
	vector<int> vv;
	n.push_back(1);
	for(int i=1;i<5;i++)
	{
		if(i%2==1)
		{
			int q=n.size();
			for(int j=0;j<q;j++)
			{
				vv.push_back((2*n.back())+1-s(n.back()));
				vv.push_back((2*n.back())+s(n.back()));
				n.pop_back();
			}
			n.clear();
		}
		if(i%2==0)
		{
			int g=vv.size();
			for(int j=0;j<g;j++)
			{
				n.push_back((2*vv.back())+1-s(vv.back()));
				n.push_back((2*vv.back())+s(vv.back()));
				vv.pop_back();
			}
			vv.clear();
		}
	}
	int g=n.size();
	for(int i=0;i<g;i++)
	{
		cout<<n.back()<<endl;
		n.pop_back();
	}
}
Leave a Comment