14522022-10-10 18:47:03lacitoSzámjegy keveréscpp11Accepted 40/403ms3764 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool van = false;
    long long muvdb = 0;
    if (s[0] == '1') {
        van = true;
    }
    for (int i = s.length()-1; i >= 0; i--)
    {
        if (!van && s[i] - '0' != 0 && i != 0) {
            van = true;
        }
        muvdb += s[i] - '0';
    }
    if (!van) {
        muvdb = s[0] - '0' + 9 * (s.length() - 1);
    }
    long long ossz = 0;
    for (int i = 1; i <= s.length() - 1; i++) {
        ossz += i;
    }
    cout << muvdb + 9 * ossz;
}

// 999 >> 991 >> 199 >> 190 >> 109 >> 100 >> 99
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/02ms2060 KiB
3Accepted0/02ms2260 KiB
4Accepted2/22ms2460 KiB
5Accepted2/22ms2668 KiB
6Accepted2/22ms2744 KiB
7Accepted2/22ms2744 KiB
8Accepted2/22ms2816 KiB
9Accepted2/22ms3024 KiB
10Accepted2/22ms3104 KiB
11Accepted4/42ms3228 KiB
12Accepted4/42ms3344 KiB
13Accepted2/22ms3372 KiB
14Accepted2/22ms3640 KiB
15Accepted2/22ms3668 KiB
16Accepted2/22ms3668 KiB
17Accepted2/22ms3764 KiB
18Accepted2/22ms3668 KiB
19Accepted3/32ms3672 KiB
20Accepted3/32ms3672 KiB