Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: kavin8888

Problemset: วิศวกรรมข้อมูล

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-12 12:45:50

#include <bits/stdc++.h>
using namespace std;
string convert_decimal_tobinary(int x)
{
	string ans="";
	while(x)
	{
		ans=((x&1)? "1":"0")+ans;
		x>>=1;
	}
	return ans;
}
int convert_binary_todecimal(string x)
{
	int ans=0;
	for(char l:x)
	{
		ans<<=1;
		ans+=((l=='1')? 1:0);
	}
	return ans;
}
int main() 
{
	int n; cin>>n;
	vector<int> k(n);
	for(int &i:k)
	{
		cin>>i;
	}
	int ans=0;
	do{
		string tmp="";
		for(int u:k)
		{
			tmp+=convert_decimal_tobinary(u);
		}
		ans=max(ans,convert_binary_todecimal(tmp));
	}while(next_permutation(k.begin(),k.end()));
	cout<<ans<<'\n';
}