P1980 [NOIP 2013 普及组] 计数问题
标程
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
long long ans = 0;
for (int i = 1; i <= n; i++) {
int t = i;
while (t > 0) {
if (t % 10 == x) ans++; // 看当前这一位是不是 x
t /= 10; // 去掉这一位,看下一位
}
}
cout << ans << "\n";
return 0;
}