Birthday Party - Basics of Operators & Basic Programming Practice Problems - HackerEarth
Birthday Party - Basics of Operators & Basic Programming Practice Problems - HackerEarth
Birthday Party
Attempted by: 2274 / Accuracy: 81% / Maximum Score: 20 / 48 Votes
Tag(s): Easy
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 di erent 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
Problem Setter:
Akash Rakshit
SAMPLE INPUT
2
5 14
3 21
SAMPLE OUTPUT
No
Yes
Explanation
?
Test Case 1:
There is no way such that he can distribute 14 chocolates among 5 friends equally.
Test Case 2:
There are 21 chocolates and 3 friends, so he can distribute chocolates eqally. Each friend will get 7
chocolates.
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino),
11
JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl,
LIVE EVENTS
PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic
CODE EDITOR
Enter your code or Upload your code as le. Save Java 8 (oracle 1.8.0_131)
1
2 import java.io.BufferedReader;
3 import java.io.InputStreamReader;
4
5 //import for Scanner and other utility classes
6 import java.util.*;
7
8 class TestClass {
9 public static void main(String args[] ) throws Exception {
10 Scanner s = new Scanner(System.in);
11 int T= s.nextInt();
12 for(int i=1;i<=T;i++)
13 {
14 int N = s.nextInt(); // Reading input from STDIN
15 int M = s.nextInt();
16 if(M%N==0)
17 {
18 System.out.println("Yes");
19 }
20 else
21 {
22 System.out.println("No");
23 }
24 }
25
26 }
27 }
28 22:36
RESULT: Accepted
Input
0.101817 64 0
#1
Input
0.109696 64 0
#2
Compilation Log
No compilation log for this submission.
COMMENTS (20)
Join Discussion...
Cancel Post
?
Press Careers
Reach Us