Advertisement
Josif_tepe

Untitled

Mar 14th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(false);
  9. int S, E;
  10. cin >> S >> E;
  11. vector<int> pals; // ke gi imame site palindromi od 3 do 99999
  12. for(int i = 3; i <= 99999; i++) {
  13. int tmp = i;
  14. vector<int> v;
  15. while(tmp > 0) {
  16. v.push_back(tmp % 10);
  17. tmp /= 10;
  18. }
  19. int L = 0;
  20. int R = v.size() - 1;
  21. bool flag = true;
  22. while(L < R) {
  23. if(v[L] != v[R]) {
  24. flag = false;
  25. break;
  26. }
  27. L += 1;
  28. R -= 1;
  29. }
  30. if(flag) {
  31. pals.push_back(i);
  32. }
  33. }
  34. vector<bool> visited(100000, false);
  35. visited[S] = true;
  36. queue<int> q;
  37. q.push(S); // momentalniot broj
  38. q.push(0); // brojot na cekori da stigneme od S do momentalniot broj
  39.  
  40. return 0;
  41. }
  42.  
  43. // S --> E
  44. // S + palindrome <= E
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement