Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
704 B
1
Indexable
Never
#include <iostream>
     
using namespace std;
 
int main() {
    int l, r;
    cin >> l >> r;
    int rez = 0;
    for(int i = l; i <= r; i++) {
        int tmp = i;
        int pal = 0;
        int dali_e_deliva = 1;
        while(tmp > 0) {
            int cifra = tmp % 10;
            tmp /= 10;
            pal = (pal * 10) + cifra;
            
            if(cifra == 0) {
                dali_e_deliva = 0;
            }
            else {
                if(i % cifra != 0) {
                    dali_e_deliva = 0;
                }
            }
        }
        
        if(pal == i or dali_e_deliva == 1) {
            rez++;
        }
    }
    
    cout << rez << endl;
 
    return 0;
}
Leave a Comment