算法:枚举
复杂度:
解题思路:
直接枚举 到
中的每个数,再依次判断每一位是否等于
即可。
C++ 代码:
#include <iostream>
using namespace std;
int main()
{
int n, x;
cin >> n >> x;
int res = 0;
for (int i = 1; i <= n; i++)
for (int j = i; j; j /= 10)
if (j % 10 == x)
res++;
cout << res << endl;
return 0;
} 
京公网安备 11010502036488号