You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
627 B

#include <bits/stdc++.h>
using namespace std;
int check(int x) {
// 转9进制
string res;
while (x) {
int a = x % 9;
res += to_string(a);
x /= 9;
}
// 每个数位都是奇数
for (int i = 0; i < res.size(); i++)
if ((res[i] - '0') % 2 == 0) return 0;
// 判断转完的9进制是不是回文数
string str = res;
reverse(str.begin(), str.end());
return str == res;
}
int main() {
int n, m;
cin >> n >> m;
int res = 0;
for (int i = n; i <= m; i++) res += check(i);
cout << res << endl;
return 0;
}