9212022-01-28 10:44:32kidesoSzámjegy keveréscpp14Accepted 40/402ms2000 KiB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	long long sum = 0;
	long long db = 0;
	for (char c : s){
		sum += c - '0';
		if (c != '0') ++db;
	}

	if (db == 1 && s[0] != '1')
		sum += (s.length() - 1) * 9;

	cout << sum + s.length() * (s.length() - 1) / 2 * 9;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1756 KiB
2Accepted0/01ms1792 KiB
3Accepted0/01ms1844 KiB
4Accepted2/21ms1840 KiB
5Accepted2/21ms1860 KiB
6Accepted2/21ms1864 KiB
7Accepted2/21ms1864 KiB
8Accepted2/21ms1864 KiB
9Accepted2/21ms1864 KiB
10Accepted2/21ms1872 KiB
11Accepted4/41ms1868 KiB
12Accepted4/41ms1880 KiB
13Accepted2/21ms1916 KiB
14Accepted2/21ms1932 KiB
15Accepted2/21ms1944 KiB
16Accepted2/21ms1952 KiB
17Accepted2/21ms1964 KiB
18Accepted2/21ms1968 KiB
19Accepted3/31ms1988 KiB
20Accepted3/31ms2000 KiB