#t50. 自幂数判断
自幂数判断
Narcissistic Number Check
Problem Description
A "narcissistic number" (also called an Armstrong number) is an -digit number whose -th powers of its decimal digits sum to the number itself. For example, is a -digit number, and the sum of the cubes of its digits is , so is narcissistic; is a -digit number, and the sum of the fourth powers of its digits is , so is narcissistic. Now, given several positive integers, determine whether each of them is a narcissistic number.
Input Format
The first line of input is a positive integer , the number of integers to be judged. It is guaranteed that .
The following lines each contain one integer to be judged. These integers are all less than .
Output Format
Output lines. For each corresponding integer, if it is a narcissistic number output the uppercase letter T, otherwise output the uppercase letter F.
Hint: you do not need to wait for all input to finish before outputting; you may judge and output each number as it is read, then read the next.
Sample Input 1
3
152
111
153
Sample Output 1
F
F
T
Sample Input 2
5
8208
548834
88593477
12345
5432
Sample Output 2
T
T
T
F
F
Sample Explanation
In the first sample, three numbers are input: , and . For , it is a -digit number, and , which is not equal to , so output F. For , , not equal to , output F. For , , equal to itself, so output T.
Constraints
Each integer to be judged is less than .