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

34367번 - Cookie Monster Concussion 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB57504486.275%

문제

Oh no! Cookie Monster got a concussion after hitting his head on his desk (he couldn't wrap his head around a bug while coding). He is currently in bed recovering, but he is starting to feel hungry and wants some cookies. However, he gets indigestion when he eats an amount of cookies that is not a multiple of 9ドル$. Due to his concussion, he temporarily forgot how to divide by 9ドル$. Luckily, he remembers a cool algorithm to determine if a number is a multiple of 9ドル$.

The algorithm is to sum the digits of the number in question, and checking if the sum is 9ドル$. If the number is greater than or equal to 10ドル,ドル then repeat the process on the sum. If and only if the sum of the digits is 9ドル,ドル then the number is a multiple of 9ドル$. Here are a few examples of the algorithm with multiples of 9ドル$. \begin{align*} 81 &\rightarrow 8 + 1 = 9 \\ 117 &\rightarrow 1 + 1 + 7 = 9 \\ 1251 &\rightarrow 1 +たす 2 +たす 5 +たす 1 = 9 \\ 99 &\rightarrow 9 + 9 = 18 \rightarrow 1 + 8 = 9 \end{align*} The following are not multiples of 9ドル$. \begin{align*} 51 &\rightarrow 5 + 1 = 6 \\ 219 &\rightarrow 2 + 1 + 9 = 12 \rightarrow 1 + 2 = 3\\ 2714 &\rightarrow 2 +たす 7 +たす 1 +たす 4 = 14 \rightarrow 1 + 4 = 5 \end{align*} Given the number of cookies Cookie Monster wants to eat, your task is to determine if Cookie Monster should eat that many cookies.

입력

The first and only line of input will contain a single integer 1ドル \leq C \leq 10^{18}$ representing the number of cookies that Cookie Monster wants to eat.

출력

Print the single-digit integer that Cookie Monster's algorithm outputs for the given number.

제한

예제 입력 1

81

예제 출력 1

9

예제 입력 2

51

예제 출력 2

6

예제 입력 3

117

예제 출력 3

9

예제 입력 4

219

예제 출력 4

3

예제 입력 5

2714

예제 출력 5

5

힌트

출처

School > CS@Mines > CS@Mines HSPC 2023 > Beginner F번

School > CS@Mines > CS@Mines HSPC 2023 > Advanced C번

  • 문제를 만든 사람: Scott Enriquez
(追記) (追記ここまで)

출처

대학교 대회

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

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