Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* http://gosucoder.com/problem/P1 */
- using System;
- public class Test
- {
- static int c;
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int[] a = new int[n];
- for (int i = 0; i < n; i++)
- a[i] = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- c = 0;
- Console.WriteLine(AmusingSum(a[i]) + " " + c);
- }
- Console.ReadLine();
- }
- static int AmusingSum(int x)
- {
- int y = Reverse(x);
- if (x == y)
- return x;
- else
- {
- c++;
- return AmusingSum(x + y);
- }
- }
- static int Reverse(int x)
- {
- int r = 0;
- do {
- r = 10 * r + x % 10;
- x /= 10;
- } while (x > 0);
- return r;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement