1 solutions

  • 0
    @ 2026-11-29 18:56:34

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long long n;
        cin >> n;
        
        if (n<=9) {
            cout << n;
            return 0;
        }
        
        long long ans = 9,q = n / 10 -1;
        
        long long low,high = n;
        low = n %10;
        while(high/10){
            high /= 10;
        }
        if (high = low) q +=1;
        ans += q;
        
        cout << ans;
        
        return 0;
    }
    

    Information

    ID
    448
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By