Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int r,l,d,a,c=0,x,y,palindrom=0,rez=0,p;
- int b[10];
- cin>>l>>r;
- for (int i=l;i<=r;i++)
- {
- p=i;
- a = 1;
- while (i>0)
- {
- d=i%10;
- if (d!=0 and p%d==0)
- {
- a=1;
- }
- else
- {
- a=0;
- break;
- }
- i/=10;
- }
- i=p;
- c=0;
- palindrom=0;
- while (i>0)
- {
- d=i%10;
- b[c] = d;
- c++;
- i/=10;
- }
- i=p;
- x=0;
- y=(c-1);
- while (x < y)
- {
- if (b[x] == b[y]){
- x++;
- y--;
- }
- else{
- palindrom++;
- break;
- }
- }
- if(a==1 or palindrom==0){
- rez++;
- }
- }
- cout<<rez<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement