提交时间:2024-02-24 10:29:11

运行 ID: 42107

#include<bits/stdc++.h> using namespace std; bool pd(int x,int k){ while(x){ if(x%k%2==0){ return false; } x/=k; } return true; } int t(int n,int k){ int pos=1; int a=0; while(n){ a=a+n%k*pos; pos*=10; n/=k; } return a; } bool reverse(int n){ int h=0; int m=n; while(n){ h=h*10+n%10; n/=10; } if(h==m){ return true; }else return false; } int main() { int n,m,cnt=0; cin>>n>>m; for(int i=n;i<=m;i++){ if(pd(i,9)&&reverse(t(i,9))){ cnt++; } } cout<<cnt; return 0; }