SNGDIV69 - Divisible by 6 and 9
Let num (> 0) be n (> 0) digit(s) positive integer. num is represented as N1N2N3N4...Nn-2Nn-1Nn, where Ni is the ith digit of num from left (0 < i < n+1). Digits of num are sorted in descending and ascending order respectively and this sorting generates two new positive integers numdsc and numasc. The difference between the numbers is diffnum = numdsc - numasc, if diffnum is divisible by both 6 and 9, then we say that num is a magic number. Let sumdigits be defined as following
number = diffnum do { number = sum of digits of number } while (number > 10) sumdigits = number
Input
First line of input is t (< 101), total number of test cases. Each test case has n (< 10001) as its first input and next n lines contains num (< 10100).
Output
For each test case, write exactly n lines containing two or three specifications without space:
- Y if num is magic number otherwise N.
- Let sumdigits = c, ZER if c is 0 (zero), ONE if c is 1 (one) if c > 1, EP if c is even and prime, ENP if c is even but not prime, OP if c is odd and prime or ONP if c is odd but not prime.
- Let diffnum = d, If num is not a magic number then print EQL if d is not divisible by both 6 and 9, LTN if d is not divisible by 6 only, GTN if d is not divisible by 9 only.
Example
Input: 1 2 31 100 Output: YONP NONPLTN
0 is divisible by 6 and 9 :)
hide comments
Piyush Kumar:
2016-07-14 05:47:54
The source code limit is unwanted. I am forced to delete the comments and other things. |
|
Rahul Jain:
2014-09-22 18:39:32
Couldn't get it.. :( |
|
Gohan:
2014-07-19 12:09:56
My 50th ........:D |
|
AvmnuSng:
2014-02-09 20:12:43
@Bhavik : I don't think code length limit has to do anything this time, because a well indented code can be submitted within 1KB limit... |
|
anurag garg:
2014-02-09 19:09:52
AC with 880 chars....nice implementation Last edit: 2014-02-10 04:14:33 |
|
Bhavik:
2014-02-09 09:29:28
first of all it's ridiculous enough to short the code to 1024B to submit and frustrating when it gives wa!!
|
|
Test:
2013-12-29 13:15:22
@Abhimanyu Singh Can you please check my submission..??getting WA submission id: 10761069 |
|
AvmnuSng:
2013-12-26 18:24:35
@bLanK : your code is generating wrong answer for very first input, I can not tell you, "why?" because I am not going to read one line code.
|
|
AvmnuSng:
2013-12-26 18:24:24
@bLanK : your code is generating wrong answer for very first input because I am not going to read one line code.
|
|
BLANKRK:
2013-12-26 15:45:16
@Abhimanyu : Can you please check my submission.? Getting WA
|
Added by: | AvmnuSng |
Date: | 2013-10-24 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
Resource: | Abhimanyu Singh My Problems |