An (XY, D)—CIRCULAR NUMBER is a number whose last two digits are X and Y, and multiplication of the number by the single digit D is equivalent to moving the last two digits (XY) to the beginning of the number. For example, the number 132832080200501253 is a (53, 4)—CIRCULAR NUMBER because 132832080200501253 * 4 = 531328320802005012. Write a program that asks for two-digit number XY and a single digit D, and prints the SMALLEST (XY, D)—CIRCULAR NUMBER or prints a message NONE if none exists. It is guaranteed that your number will not exceed 255 digits.
INPUTAn integer number, N, indicating the total number of cases. On each of the next N lines are the two-digit number XY and the single digit D, separated by a space.
OUTPUTThe smallest circular number (if one exists with less than 255 digits) that satisfies the given condition; otherwise output the message NONE.
1 53 4
Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Feb 24, 2009
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3