Make Multiple CodeChef Solution

Problem – Make Multiple CodeChef Solution

Chef has two integers A and B (AB).

Chef can choose any non-negative integer X and add them to both A and B. Find whether it is possible to make A a divisor of B.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two integers A and B.

Output Format

For each test case, output YES if it is possible to make A a factor of BBNO otherwise.

You can print each character of the string in uppercase or lowercase. For example, the strings YesYESyes, and yEs, are all considered identical.

Constraints

  • 1≤T≤10^5
  • 1≤AB≤10^9

Sample 1:

Input:
3
3 6
4 14
9 10
Output:
YES
YES
NO

Explanation:

Test case 1: We can choose X=0 and add them to 3 and 6. Thus, 3 is a factor of 6.

Test case 2: We can choose X=1 and add them to 4 and 14. Thus, 4+1=5 is a factor of 14+1=15.

Test case 3: There is no possible value of X to add such that A becomes a factor of B.

Make Multiple CodeChef Solution in Pyth 3

# cook your dish here

T=int(input())
for i in range(T):
    a,b=map(int,input().split())
    x=b-a
    if x<a and x!=0:
        print("NO")
    else:
        print("YES")

Make Multiple 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();
		while(t-- > 0)
		{
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    
		    if(b%a==0||b-a>a)
		    {
		        System.out.println("YES");
		    }
		    else
		        System.out.println("NO");
		}
	}
}

Make Multiple CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	int flag=1;
	while(t--){
	    int a,b;
	    cin>>a>>b;
	    if(b%a==0){
	        cout<<"YES"<<endl;
	    }
	    else if((b/a)>1){
	        cout<<"YES"<<endl;
	    }
	    else{
	        cout<<"NO"<<endl;
	    }
	   
	}	

	return 0;
}
Make Multiple CodeChef Solution Review:

In our experience, we suggest you solve this Make Multiple 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 Make Multiple CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Make Multiple 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

Leave a Reply

Your email address will not be published. Required fields are marked *