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.

61 lines
1.3 KiB

#include <bits/stdc++.h>
using namespace std;
int f;//楼层
int n;//房间数
/**
* 功能:获取房间号
* @param i 楼层
* @param j 房间
* @return
*/
string fjh(int i, int j) {
string h;
if (j < 10) h = to_string(i) + '0' + to_string(j);
else h = to_string(i) + to_string(j);
return h;
}
/**
* 功能:判断指定字符串是否为反过来一样的字符串
* @param x
* @return
*/
bool flag(string x) {
string res;
//第一步:对应转换
//1,8,0掉过来是一样
//6,9掉后是9,6
// char nums[] = {'0', '1', '0', '0', '0', '0', '9', '0', '8', '6'};
// for (int i = 0; i < x.size(); i++)
// res += nums[x[i] - '0'];
for (int i = 0; i < x.size(); i++) {
if (x[i] == '6')res += '9';
else if (x[i] == '9')res += '6';
else if (x[i] == '1')res += '1';
else if (x[i] == '0')res += '0';
else if (x[i] == '8')res += '8';
}
//第二步:镜子翻转
reverse(res.begin(), res.end());
//对比是不是一样
return res == x;
}
int res;
int main() {
//读入
cin >> f >> n;
for (int i = 1; i <= f; i++)
for (int j = 1; j <= n; j++) {
string x = fjh(i, j);
if (flag(x)) res++;
}
//输出
cout << res << endl;
return 0;
}