9192022-01-28 10:38:39kidesoSzámjegy keveréscpp14Wrong answer 18/402ms1996 KiB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

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

	cout << sum + db * (db - 1) / 2 * 9;


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base18/40
1Accepted0/02ms1736 KiB
2Accepted0/01ms1784 KiB
3Wrong answer0/01ms1840 KiB
4Accepted2/21ms1848 KiB
5Accepted2/21ms1852 KiB
6Accepted2/21ms1856 KiB
7Accepted2/21ms1868 KiB
8Wrong answer0/21ms1864 KiB
9Accepted2/21ms1868 KiB
10Wrong answer0/22ms1868 KiB
11Accepted4/41ms1872 KiB
12Wrong answer0/41ms1876 KiB
13Wrong answer0/22ms1912 KiB
14Accepted2/22ms1916 KiB
15Wrong answer0/22ms1932 KiB
16Wrong answer0/21ms1936 KiB
17Wrong answer0/21ms1956 KiB
18Accepted2/22ms1960 KiB
19Wrong answer0/32ms1984 KiB
20Wrong answer0/31ms1996 KiB