spoj BCPALIN


SUBMITTED BY: Guest

DATE: Feb. 16, 2014, 9:25 a.m.

FORMAT: C++

SIZE: 661 Bytes

HITS: 956

  1. //Haha TTpro
  2. //BCPALIN
  3. //http://www.spoj.com/PTIT/problems/BCPALIN/
  4. #include <iostream>
  5. using namespace std;
  6. bool doixung (int A);
  7. int main()
  8. {
  9. int A;
  10. int t;
  11. cin >>t;
  12. for (int i=1;i<=t;i++)
  13. {
  14. cin>>A;
  15. if (doixung(A)) cout<<"YES" ; else cout<<"NO";
  16. cout<<endl;
  17. }
  18. return 0;
  19. }
  20. bool doixung (int A)
  21. {
  22. int a=A;
  23. int b=0; // so sau khi tach
  24. int x; // tach so
  25. while (a!=0)
  26. {
  27. b=b*10;
  28. x=a%10;
  29. a=a/10;
  30. b=b+x;
  31. }
  32. if (A==b) return true;
  33. return false;
  34. }

comments powered by Disqus