23872023-01-12 12:28:05sztomiSzámjegy keveréscpp11Accepted 40/403ms3872 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int sum = 0;
    int nem0db = 0;
    for(char c : s){
        sum += c-'0';
        nem0db += c!='0';
    }

    // 200 -> 199
    // 30

    long long ki = sum;
    if(nem0db == 1 && s[0] != '1'){
        ki += (n-1)*9;
    }
    ki += n*(n-1)/2*9;

    cout << ki << "\n";

}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1680 KiB
2Accepted0/02ms1936 KiB
3Accepted0/02ms2140 KiB
4Accepted2/22ms2340 KiB
5Accepted2/22ms2588 KiB
6Accepted2/22ms2792 KiB
7Accepted2/22ms2740 KiB
8Accepted2/22ms2864 KiB
9Accepted2/22ms3076 KiB
10Accepted2/22ms3256 KiB
11Accepted4/42ms3460 KiB
12Accepted4/42ms3532 KiB
13Accepted2/22ms3556 KiB
14Accepted2/22ms3656 KiB
15Accepted2/22ms3656 KiB
16Accepted2/22ms3560 KiB
17Accepted2/22ms3564 KiB
18Accepted2/22ms3688 KiB
19Accepted3/32ms3776 KiB
20Accepted3/32ms3872 KiB