304 North Cardinal St.
Dorchester Center, MA 02124

# Jenga Night CodeChef Solution

## Problem – Jenga Night CodeChef Solution

Chef hosts a party for his birthday. There are N people at the party. All these N people decide to play Jenga.

There are X Jenga tiles available. In one round, all the players pick 1 tile each and place it in the tower.
The game is valid if:

• All the players have a tile in each round;
• All the tiles are used at the end.

Given N and X, find whether the game is valid.

### Input Format

• First line will contain T, the number of test cases. Then the test cases follow.
• Each test case contains a single line of input, containing two space-separated integers N and X representing the number of people at the party and the number of available tiles respectively.

### Output Format

For each test case, output in a single line YES if the game is valid, else output NO.

You may print each character of the string in uppercase or lowercase (for example, the strings YeS, yEs, yes and YES will all be treated as identical).

• 1≤T≤10^4
• 1≤N,X≤1000

### Sample 1:

``````Input: 3
3 3
4 2
2 4
Output: YES
NO
YES``````

### Explanation:

Test case 1: The game will last for 1 round after which the tiles will finish.

Test case 2: There are not enough Jenga tiles for everyone to place.

Test case 3: The game will last for 2 rounds as after round 2 all Jenga tiles are used.

## Jenga Night CodeChef Solution in C++17

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
int n,x;
cin>>n>>x;

if(x%n == 0) {
cout<<"YES\n";
}
else {
cout<<"NO\n";
}
}

return 0;
}
``````

## Jenga Night CodeChef Solution in Pyth 3

``````# cook your dish here
n=int(input())
for i in range(n):
x,y=[int(a) for a in input().split()]
if y%x==0:
print("YES")
else:
print("NO")``````

## Jenga Night CodeChef Solution in Java

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();

for(int i=0;i<t;i++){
int n=sc.nextInt();
int x=sc.nextInt();

if(x>=n && x%n==0){

System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
}
``````
##### Jenga Night CodeChef Solution Review:

In our experience, we suggest you solve this Jenga Night CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Jenga Night CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this Jenga Night CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions