Advertisement
juanjo12x

UVA_10018_Reverse_And_Add

Aug 5th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stdio.h>
  4. #include <algorithm>
  5. #include <cstring>
  6. #include <iostream>
  7. #include <cstdio>
  8. #include <algorithm>
  9. #include <cstring>
  10. #include <string>
  11. #include <cctype>
  12. #include <stack>
  13. #include <queue>
  14. #include <list>
  15. #include <vector>
  16. #include <map>
  17. #include <set>
  18. #include <sstream>
  19. #include <stdlib.h>
  20. #include <cmath>
  21. #define LL unsigned long long
  22. using namespace std;
  23. int main()
  24. {
  25.     long long  n,a,s,c;
  26.     int t,i;
  27.     while(scanf("%d",&t)==1)
  28.     {
  29.         for(i=1;i<=t;i++)
  30.         {
  31.             scanf("%lld",&n);
  32.         a=n;
  33.         c=0;
  34.         while(1)
  35.         {
  36.             s=0;
  37.         while(n!=0)
  38.             {
  39.                 s=s*10+n%10;
  40.                 n/=10;
  41.             }
  42.         if(s==a)
  43.         break;
  44.         else
  45.         {
  46.         n=s+a;
  47.         a=s+a;
  48.         c++;
  49.         }
  50.  
  51.     }
  52.     printf("%lld %lld\n",c,a);
  53.         }
  54.     }
  55.  
  56.    return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement