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
720 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int b[N], bl;
bool check(int x) {
bl = 0;
// 1、转九进制
while (x) {
int a = x % 9;
// 2、检查在九进制情况下每个数位是不是奇数
if (a % 2 == 0) return false;
b[++bl] = a; // 将每个数位增加到b数组中
x /= 9;
}
// 3、检查在九进制情况下是不是回文数
for (int i = 1, j = bl; i <= j; i++, j--)
if (b[i] != b[j]) return false;
return true;
}
int main() {
int n, m, cnt = 0;
cin >> n >> m;
for (int i = n; i <= m; i++)
if (check(i)) cnt++;
cout << cnt << endl;
return 0;
}