1 条题解

  • 0
    @ 2025-8-27 19:51:06

    C++ :

    #include <iostream>
    using namespace std;
    int check(int x, int y) {
    int cnt = 0;
    while (x > 0) {
    int tmp = x % 10;
    if (tmp == y) {
    cnt++;
    }
    x = x / 10;
    }
    return cnt;
    }
    int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
    ans += check(i, k);
    }
    cout << ans << endl;
    return 0;
    }
    
    • 1

    信息

    ID
    5334
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者