1 solutions

  • 2
    @ 2024-11-17 20:51:50
    #include<bits/stdc++.h>
    using namespace std;
    int L,R,c,d,ans,i;
    int main()
    {
        cin>>L>>R;
        for(i=L;i<=R;i++){
            c=i;
            while(c!=0){
                d=c%10;
                c=c/10;
                if(d==2)
                    ans++;
            }
        }
        cout<<ans;
        
        return 0;
    }
    
    • 1

    Information

    ID
    412
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    (None)
    # Submissions
    18
    Accepted
    11
    Uploaded By