fork(2) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int odwrocona(int n)
  5. {
  6. int ile_cyfr;
  7. ile_cyfr=floor(log10(n)+1);
  8. int wynik=0;
  9. for(int i=1;i<=ile_cyfr;i++)
  10. {
  11. wynik += floor(pow(10.0,ile_cyfr-i))* (n%10);
  12.  
  13. n /=10;
  14. }
  15. return wynik;
  16. }
  17. int x,n,indeks=0;
  18. int ile,test;
  19. int main()
  20. {
  21. cin>>test;
  22. for(int i=0;i<test;i++)
  23. {
  24. cin>>x;
  25. int liczba_od;
  26. liczba_od=odwrocona(x);
  27. if(x==odwrocona(x)) x=odwrocona(x);
  28. else{
  29. while(x!=liczba_od);
  30. {
  31.  
  32. x+=liczba_od;
  33. liczba_od=odwrocona(x);
  34. indeks++;
  35. }
  36. }
  37. cout<<x<<" "<<indeks<<endl;
  38. }
  39. return 0;
  40. }
Time limit exceeded #stdin #stdout 5s 16064KB
stdin
3
28
68
5
stdout
Standard output is empty