DIGITROOT - Digit Root
A Digit Root is a feature of numbers used in mathematical recreation, but can also be used to check the results of simple operations such as sum and multiplication. One of its main properties is that the Digit Root of a number is always equal to Digit Root of the sum of its digits.
For example, the Digit Root of 18446744073709551615 is the same as 87 because 1+8+4+4+6+7+4+4+0+7+3+7+0+9+5+5+1+6+1+5=87, and is the same of 15 because 8+7=15, which in turn is the same as 6, since 1+5=6. Therefore the Digit Root of all these numbers is 6 since 6 is its own Digit Root.
Your task is, given the two integers, B and E, calculate the Digit Root of BE (B raised to th E-th power).
The input consists of two lines. The first contains the number B (1 ≤ B ≤ 10105). The second contains the number E (1 ≤ E ≤ 10105).
The output consists of a single line containing theDigit Root.
good question for mathmatics
+5.Last edit: 2019-01-01 12:28:39
Apply Mathematics otherwise it is not accepted because range are very very large.It can not be calculated in given time interval.
Francisco Elio Parente Arcos Filho [UEA]:
Look your code carrefully... its something wrong. Maybe you should look at the limits too.Last edit: 2018-12-28 19:22:06
I was accepted with Python 2.7, now I get wrong answer with c++14...??Last edit: 2018-12-30 09:41:31