Submit | All submissions | Best solutions | Back to list |
PSYCHO2 - Psycho Function |
The number N is called “Psycho Number”. Psycho Number is calculated as follows:
First, If we factorize N, then we have some prime and their power. Assume that, there are M powers. From M powers, you should count the number of even and odd powers. Then if the number of even power is strictly greater than odd power, then we call the number N is “Psycho Number”, otherwise the number N is call “Ordinary Number”.
As for example, if N = 67500 then prime factorization,
67500 = 22 x 33 x 54.
Count even powers and odd powers. This number have 2 even power (2, 4) and 1 odd power (3). Since even power 2 (2, 4) is greater than odd power 1 (3), so the number 67500 is a Psycho Number.
bool isPsycho( long long K, long long b, long long p) { N = numberoftrailingzeros(K!) * lastdigit(bp); if (N == psychonumber) return true; else return false; }
For example, if k = 10, b = 12, p = 1 then the N is 4 and it's a psycho number.
10! = 3628800, number of trailing zeros is 2.
121 = 12, last digit is 2.
so N = 4 then 4 = 22. Even power is greater than odd power, so the number 4 is a Psycho Number.
Input:
An integer T (1<= T <=105) denoting the number of test cases followed by T lines. Each line containing K (1<= K <=4*106), b (0<= b <=104), and p (0<= p <=1017).
Output:
For each case print “Psycho Number” or “Ordinary Number”.
Sample
Input 2 5 2 5 10 12 1 Output Ordinary Number Psycho Number
Note : 0 and 1 is not a psycho number.
Psycho 1: Psycho
Psycho 3: Make Psycho
Psycho 4: Psycho34 (easy)
Problem setter: Shipu Ahamed, Dept. of CSE, Bangladesh University of Business and Technology (BUBT)
Added by: | Shipu Ahamed |
Date: | 2013-11-05 |
Time limit: | 0.5s |
Source limit: | 8000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
2017-07-21 19:24:44
move to classical plz... its worth it |
|
2016-08-14 08:13:12 Vipul Srivastava
I think this should be in the classical section. Involves many tasks and can teach a few concepts also the brute force won't pass. Last edit: 2016-08-15 08:58:30 |