Files
python/LuoGu/RuMen/P1980.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

29 lines
625 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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