FA
Time limit1sMemory limit128 MB
Starting from a huge integer x, repeatedly replace it with (first digit) times (digit count) and report whether the sequence eventually cycles forever.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Simulation, Hash map
- Solved
- No attempts yet
Problem
The function returns the first digit of multiplied by the number of digits of .
For example, if , the first digit is and the number of digits is , so .
Apply to the given , then apply to the result, and keep repeating. If the same number keeps coming out from some point on, is called an FA number.
Decide whether is an FA number.
Input
The first line contains an integer ().
Output
Print FA if is an FA number, and NFA otherwise.