# Byte to Bit Codechef Solution

Byte to Bit Codechef Solution: Hello coders, today we are going to solve Byte to Bit Codechef Solution.

## Problem

In the magical land of Byteland, there are three kinds of citizens:

• a Bit â€“Â 2ms2msÂ after a Bit appears, it grows up and becomes a Nibble (i.e. it disappears and a Nibble appears)
• a Nibble â€“Â 8ms8msÂ after a Nibble appears, it grows up and becomes a Byte
• a Byte â€“Â 16ms16msÂ after a Byte appears, it grows up, splits into two Bits and disappears

Chef wants to know the answer to the following question: what would the population of Byteland be immediately before the timeÂ NmsNmsÂ if only 1 Bit appeared at timeÂ 0ms0ms?

Help him and find the population (number of citizens) of each type.

### Input

• The first line of the input contains a single integerÂ TTÂ denoting the number of test cases. The description ofÂ TTÂ test cases follows.
• The first and only line of each test case contains a single integerÂ NN.

### Output

For each test case, print a single line containing three space-separated integers â€” the number of Bits, Nibbles and Bytes.

### Constraints

• 1â‰¤Tâ‰¤1041â‰¤Tâ‰¤104
• 1â‰¤Nâ‰¤1,6001â‰¤Nâ‰¤1,600

Subtask #2 (75 points):Â original constraints

```2
2
3
```

```1 0 0
0 1 0
```

### Explanation

Immediately before the timeÂ 2ms2ms, there is only one Bit. AtÂ 2ms2ms, this Bit grows up, so immediately beforeÂ 3ms3ms, there is only one Nibble in Byteland.

## Byte to Bit â€“ CodeChef Solution in JAVA

```import java.util.Scanner;
class Byte_to_Bit {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
while(t-- > 0) {
int n = input.nextInt();
long ans = 1;
while(n > 26) {
ans *= 2;
n -= 26;
}
if (n<=2) {
System.out.println(ans + " 0" + " 0");
} else if (n>2 && n<= 10) {
System.out.println("0 " + ans + " 0");
} else {
System.out.println("0 " + "0 " + ans);
}
}
input.close();
}
}```

## Byte to Bit â€“ CodeChef Solution in CPP

```#include <iostream>
using namespace std;
#define ll long int
int main() {
int t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll x=1,y=0,z=0;
ll count=0;
while(1)
{
count+=2;
if(count>=n)
{
break;
}
else
{
y=x;
x=0;
count+=8;
if(count>=n)
{
break;
}
else
{
z=y;
y=0;
count+=16;
if(count>=n)
{
break;
}
else
{
x=2*z;
z=0;
}
}
}
}
cout<<x<<" "<<y<<" "<<z<<endl;
}
return 0;
}```

## Byte to Bit- CodeChef Solution in Python

```for _ in range(int(input())):
n=int(input())
if(n%26==0):
a=n//26-1
else:
a=n//26
a=2**a
b=n%26
if b in range(1,3):
print(a,0,0)
elif b in range(3,11):
print(0,a,0)
else:
print(0,0,a)```

Disclaimer:Â The above Problem (Byte to BitÂ ) is generated byÂ CodeChef but the solution is provided byÂ Â Chase2learn.This tutorial is only forÂ EducationalÂ andÂ LearningÂ purpose.

Sharing Is Caring