Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- int L, R;
- cin >> L >> R;
- int count_zimson = 0;
- for(int i = L; i <= R; i++) {
- int tmp = i;
- int divisible = 0;
- while(tmp > 0) {
- int digit = tmp % 10;
- if(digit != 0 and i % digit == 0) {
- divisible = 1;
- }
- else {
- divisible = 0;
- break;
- }
- tmp /= 10;
- }
- if(divisible == 1) {
- count_zimson++;
- continue;
- }
- int niza[6];
- tmp = i;
- int c = 0;
- while(tmp > 0) {
- niza[c] = tmp % 10;
- tmp /= 10;
- c++;
- }
- int l = 0, r = c - 1;
- int is_palindrome = 0;
- while(l <= r) {
- if(niza[l] == niza[r]) {
- l++;
- r--;
- is_palindrome = 1;
- }
- else {
- is_palindrome = 0;
- break;
- }
- }
- if(is_palindrome == 1) {
- count_zimson++;
- }
- }
- cout << count_zimson << endl;
- return 0;
- }
- /*
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement