'commit'
This commit is contained in:
30
TangDou/LanQiaoBei/LanQiao14STEMA202303/3.cpp
Normal file
30
TangDou/LanQiaoBei/LanQiao14STEMA202303/3.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user