Submit | All submissions | Best solutions | Back to list |
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 :)
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 |
hide comments
|
||||||
2013-12-23 19:32:46 shiv prasad chabarval
my 800th submission and this time AC :) Last edit: 2013-12-23 20:16:19 |
||||||
2013-12-22 15:13:34 Pradyumna Newalkar
Easy Problem.. :) :) |
||||||
2013-11-16 15:30:36 AvmnuSng
@shanmukha boora May be you should use more clear format to print string, and go through the logic again |
||||||
2013-11-16 13:41:45 Shanmukha Boora
@Abhimanyu Singh can u please check my submission...getting WA |
||||||
2013-11-16 11:23:00 AvmnuSng
@surendra : I am saying again, with proper indentation, you can write code within 1024B and actually you will hardly cross the limit, if you don't know that there is nothing in the problem. So thing again may be you can submit the code in 0.00sec than 0.20sec:) And there is one more problem like this problem, Number Magic II Last edit: 2013-11-01 08:56:14 |
||||||
2013-11-16 11:23:00 Surendra
@Abhimanyu : 1024B is not good enough to use normal code styles |
||||||
2013-11-16 11:23:00 AvmnuSng
source code limit is very fine and i guess its more than enough. |
||||||
2013-11-16 11:23:00 ήάέέϻ Ÿ
Very strict source limit for me :( |
||||||
2013-11-16 11:23:00 Mostafa 36a2
Thanks .. But i still think "Digits of num are sorted" is a past sentence .. better to change it to : if you sort Digits of num in descending and ascending order ,so that generates ... Thank you |
||||||
2013-11-16 11:23:00 AvmnuSng
@Lakshman : You are making spelling mistake, all the other things are fine :) |