2 solutions

  • 0
    @ 2023-8-2 14:45:03
    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        int n=0,M=0;
       
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            int a=i;
            while(a>0)
            {
                if(a%10==1)
                {
                    M=M+1;
                }
                a=a/10;
            }
        }
        cout<<M;
        return 0;
    }
    

    Information

    ID
    554
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    8
    Tags
    # Submissions
    66
    Accepted
    26
    Uploaded By