22892023-01-09 13:34:42rennSzámjegy keveréscpp11Accepted 40/403ms3968 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    cin.tie(0);
    iostream::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    if(s.size() == 1){
        cout << s << "\n";
        return 0;
    }
    
    long long ki = 0;
    long long sum = 0;
    int db = 0;
    for(char c : s){
        sum += c-'0';
        db += c != '0';
    }
    
    if (db == 1 && s[0] != '1')
		sum += (s.length() - 1) * 9;
    
    ki = sum;
    
    long long hossz = s.size()-1;
        
    while(hossz > 0){
        sum = 9*hossz;
        ki += sum;
        hossz--;
    }
    
    cout << ki << "\n";
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1824 KiB
2Accepted0/02ms2144 KiB
3Accepted0/02ms2288 KiB
4Accepted2/22ms2424 KiB
5Accepted2/22ms2424 KiB
6Accepted2/22ms2612 KiB
7Accepted2/22ms2772 KiB
8Accepted2/22ms2972 KiB
9Accepted2/22ms3184 KiB
10Accepted2/22ms3256 KiB
11Accepted4/42ms3384 KiB
12Accepted4/42ms3456 KiB
13Accepted2/22ms3608 KiB
14Accepted2/22ms3684 KiB
15Accepted2/22ms3968 KiB
16Accepted2/22ms3904 KiB
17Accepted2/22ms3900 KiB
18Accepted2/22ms3900 KiB
19Accepted3/32ms3896 KiB
20Accepted3/32ms3904 KiB