Problem: Contest Page | CodeChef

# DIFFICULTY:

EASY.

# PROBLEM:

The chef was not happy with the binary number system, so he designed a new machine which is having 6 different states, i.e. in binary there is a total of 2 states as 0 and 1. Now, the chef is confused about how to correlate this machine to get an interaction with Integer numbers, when N(Integer number) is provided to the system, what will be the Nth number that system will return(in Integer form), help the chef to design this system.

# Program:

```
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
long long powers_6[25];
powers_6[0]=1;
for(int i = 1; i<=23; i++)
powers_6[i]=6*powers_6[i-1];
while(t--){
int n;
cin>>n;
int a[30] = {0};
int i =0;
int m = n;
while(m>0)
{
a[i++] = m%2;
m/=2;
}
long long sum = 0;
for(int j = i-1; j>=0; j--)
{
if(a[j]==1)
sum += powers_6[j];
}
cout<<sum<<'\n';
}
return 0;
}
```