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;
int mycount(const int n, int x) {
int all = 0;
//n不能进行修改,需要克隆出来一个v
int v = n;
//循环求出此数的每一位
while (v > 0) {
int gewei = v % 10; //套路!
v = v / 10;
if (gewei == x) all++;
}
return all;
int main() {
ios::sync_with_stdio(false); //读入输出优化的强迫症
int n, x;
cin >> n >> x;
int allcount = 0;
for (int i = 1; i <= n; i++) {
allcount += mycount(i, x);
cout << allcount << endl;
return 0;