Files
python/TangDou/LanQiaoBei/LanQiao14STEMA202303/3.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
720 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}