You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
426 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, x, cnt = 0;
cin >> n >> x, x += '0';
char buf[40];
for (int i = 1; i <= n; i++)
{
sprintf(buf, "%d", i);
for (char *p = buf; *p; p++)
if (*p == x)
cnt++;
}
cout << cnt;
return 0;
}