BIRTHDAY PARTY

SOLUTION FOR BIRTHDAY PARTY HACKEREARTH


Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after party. He went to a shop to buy a packet of chocolates.
At chocolate shop, each packet is having different number of chocolates. He wants to buy such a packet which contains number of chocolates, which can be distributed equally among all of his friends.
Help Mr. X to buy such a packet.
Input:
First line contains T, number of test cases.
Each test case contains two integers, N and M. where is N is number of friends and M is number number of chocolates in a packet.
Output:
In each test case output "Yes" if he can buy that packet and "No" if he can't buy that packet.
Constraints:
1<=T<=20
1<=N<=100
1<=M<=10^5
SAMPLE INPUT
 
2
5 14
3 21
SAMPLE OUTPUT
 
No
Yes


SOLUTION :

#include<stdio.h>
int main(){
    long int t,n,m;
    scanf("%ld\n",&t);
    while(t--){
        scanf("%ld %ld\n",&n,&m);
        if(m%n==0)
        printf("Yes\n");
        else
        printf("No\n");
    }
    return 0;
}

Comments

  1. T=int(input("enter your number:"))
    for i in range(T):
    N=int(input("enter your no of persons:"))
    M=int(input("enter no of chacolates:"))
    if M%N==0:
    print("yes")
    else:
    print("No")


    #python code

    ReplyDelete
  2. Michael is celebrating his 10th birthday and he wished to arrange a party to all his class mate But there are n tough guys amongst his class who are weird. They thought that this is the best occasion for testing their friendship with him. They put up conditions before Michael that they will break the friendship unless he gives them a grand party on their chosen day Formally, th friend will break his friendship if he does not receive a grand party on dith day Michael is not a lavish spender and can give at most one grand party daily. Also, he wants to invite only one person in a party. So he just wonders what the maximum number of friendships

    he can save.

    Please help Michael in this difficult task.

    ReplyDelete

Post a Comment

Popular posts from this blog

spoj CPTTRN1 - Character Patterns (Act 1) solution

ROY AND PROFILE PICTURE