Skip to content

Commit 4b69b1e

Browse files
Add files via upload
1 parent 09d8b1c commit 4b69b1e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
We try to maximise the number of 9s in the digit sum
2+
3+
4+
Let A = all 9s except the first digit.
5+
6+
B = N - A
7+
8+
-----------------------
9+
10+
int main()
11+
{
12+
string N;
13+
cin >> N;
14+
15+
string A;
16+
A = N[0] - 1;
17+
for(int i = 1; i < N.size(); i++)
18+
A += '9';
19+
20+
long long n = to_int(N), a = to_int(A);
21+
long long b = n - a;
22+
23+
cout << digit_sum(a) + digit_sum(b);
24+
return 0;
25+
}

0 commit comments

Comments
 (0)