1 solutions

  • 0
    @ 2024-6-11 16:19:34

    枚举+拆数(100pts)

    • 枚举每个数,然后进行拆数统计xx出现的个数
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,x;
        cin>>n>>x;
        int res=0;
        for(int i=1;i<=n;i++) //枚举范围
        {
            int t=i;
            while(t) //拆数模板
            {
                int ge=t%10;
                if(ge==x)
                {
                    res++;
                }
                t/=10;
            }
        }
        cout<<res;
        return 0;
    }
    
    • 1

    Information

    ID
    441
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    2
    Accepted
    2
    Uploaded By