• 沒有找到結果。

9339 Resulting palindrome In this particular case the palindrome ‘9339’ appeared after the 4th addition

N/A
N/A
Protected

Academic year: 2021

Share "9339 Resulting palindrome In this particular case the palindrome ‘9339’ appeared after the 4th addition"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

10018 Reverse and Add

The “reverse and add” method is simple: choose a number, reverse its digits and add it to the original.

If the sum is not a palindrome (which means, it is not the same number from left to right and right to left), repeat this procedure.

For example:

195 Initial number 591

—–

786 687

—–

1473 3741

—–

5214 4125

—–

9339 Resulting palindrome

In this particular case the palindrome ‘9339’ appeared after the 4th addition. This method leads to palindromes in a few step for almost all of the integers. But there are interesting exceptions. 196 is the first number for which no palindrome has been found. It is not proven though, that there is no such a palindrome.

You must write a program that give the resulting palindrome and the number of iterations (addi- tions) to compute the palindrome.

You might assume that all tests data on this problem:

• will have an answer ,

• will be computable with less than 1000 iterations (additions),

• will yield a palindrome that is not greater than 4,294,967,295.

Input

The first line will have a number N (0 < N ≤ 100) with the number of test cases, the next N lines will have a number P to compute its palindrome.

Output

For each of the N tests you will have to write a line with the following data : minimumnumberofiterations(additions)togettothepalindrome and theresultingpalindromeitself sep- arated by one space.

Sample Input 3

195 265 750

(2)

Universidad de Valladolid OJ: 10018 – Reverse and Add 2/2

Sample Output 4 9339

5 45254 3 6666

參考文獻

相關文件

In addition, this paper covers issues relating to the types of concern for the elderly in the day-care services offered by Venerable Master Hsing Yun's Humanistic Buddhism,

compiler on the four memory segments static, this, local, argument In addition, there are four additional memory segments, whose role will. The VM’s

The static, private, local and argument variables are mapped by the compiler on the four memory segments static , this , local , argument. In addition, there are four

6 《中論·觀因緣品》,《佛藏要籍選刊》第 9 冊,上海古籍出版社 1994 年版,第 1

Teachers may consider the school’s aims and conditions or even the language environment to select the most appropriate approach according to students’ need and ability; or develop

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

好了既然 Z[x] 中的 ideal 不一定是 principle ideal 那麼我們就不能學 Proposition 7.2.11 的方法得到 Z[x] 中的 irreducible element 就是 prime element 了..

another direction of world volume appears and resulting theory becomes (1+5)D Moreover, in this case, we can read the string coupling from the gauge field and this enables us to