#P8680. [蓝桥杯 2019 省 B] 特别数的和

[蓝桥杯 2019 省 B] 特别数的和

Description

Xiaoming is very interested in numbers whose digits contain 22, 00, 11, or 99 (excluding leading 00). From 11 to 4040, such numbers include 11, 22, 99, 1010 through 3232, 3939, and 4040, for a total of 2828 numbers, and their sum is 574574.

Given nn, find the sum of all such numbers from 11 to nn.

Input Format

Input one line containing an integer nn.

Output Format

Output one line containing an integer, which is the sum of the numbers that satisfy the condition.

40
574

Hint

For 20%20\% of the test cases, 1n101 \le n \le 10.

For 50%50\% of the test cases, 1n1001 \le n \le 100.

For 80%80\% of the test cases, 1n10001 \le n \le 1000.

For all test cases, 1n100001 \le n \le 10000.

Lanqiao Cup 2019 Provincial Contest B Group, Problem F.

Translated by ChatGPT 5