Friends and Chocolates
All submissions for this problem are available.
Mayank is on a trip to Singapore with his friends Ankur, Abhishek and Raju.
Having spent nearly whole of the day walking, visiting places and after hours of sightseeing they decide to eat something. Ankur loves chocolates so he goes and purchases some chocolates.
Now they have a lot of chocolates to eat. It’s time now to share the chocolates.
Being best of the friends they will be HAPPY only if they are able to divide chocolates equally among themselves otherwise they will be SAD.
So given the number of chocolates, you have to determine whether they will be HAPPY or SAD.
Note: They can’t cut or break any chocolate into parts.
First line of input contains a single integer T, denoting number of test cases.
First line of each test case contains a single integer N, denoting number of chocolates.
For each test case print "HAPPY" or "SAD" depending upon whether they can divide the chocolates equally or not.
1 ≤ T ≤ 103
1 ≤ N ≤ 1018
Input: 3 8 27 31
Output: HAPPY SAD SAD
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions