Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <queue>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int L, R;
- cin >> L >> R;
- int brojac = 0;
- for(int i = L; i <= R; i++) {
- int tmp = i;
- int site_cifri_se_delivi = 1;
- while(tmp > 0) {
- int cifra = tmp % 10;
- if(cifra == 0) {
- site_cifri_se_delivi = 0;
- break;
- }
- if(i % cifra != 0) {
- site_cifri_se_delivi = 0;
- break;
- }
- tmp /= 10;
- }
- int e_palindrom = 1;
- vector<int> v;
- tmp = i;
- while(tmp > 0) {
- v.push_back(tmp % 10);
- tmp /= 10;
- }
- int a = 0, b = v.size() - 1;
- while(a < b) {
- if(v[a] != v[b]) {
- e_palindrom = 0;
- break;
- }
- a += 1;
- b -= 1;
- }
- if(e_palindrom == 1 or site_cifri_se_delivi == 1) {
- brojac += 1;
- }
- }
- cout << brojac << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement