Logo
(追記) (追記ここまで)

31390번 - Physical Education 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB1073100.000%

문제

Once a week android Vasya attends his PE classes. His trainer believes that an ability to think has to be trained as well as physical skills. That is why the trainer often gives his group some tasks which are not quite easy to complete.

Today's task was the following one. Initially $n$ androids stood in one line. The trainer distributed among them different numbers in a decimal notation. All numbers were from 1ドル$ to $n$ according to the order in which the androids stood, from left to right. On the trainer's command students should re-form the line in a new order. Any two neighboring androids in the new line should meet one of the following conditions:

  • the sum of digits in the left android's number is less than the sum of digits in the right android's number;
  • the sums of digits in their numbers are equal and the left android's number is less than the right one's.

The group was completing the task very slowly. But Vasya found it very boring as he was the first in the line and didn't have to change his place.

While the androids were re-forming, Vasya decided to determine how many of them didn't need to change their places. Help him to count this.

입력

The only line contains an integer $n$ that is the number of androids in the group (2ドル \leq n \leq 10^9$).

출력

Output the number of androids who didn't have to change their places.

제한

예제 입력 1

19

예제 출력 1

3

힌트

New order is 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15, 7, 16, 8, 17, 9, 18, 19. Androids 18 and 19 along with Vasya didn't have to change their places.

출처

Contest > Open Cup > 2014/2015 Season > Stage 14: Grand Prix of East and West G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /