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