| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 57 | 50 | 44 | 86.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.
81
9
51
6
117
9
219
3
2714
5
School > CS@Mines > CS@Mines HSPC 2023 > Beginner F번
School > CS@Mines > CS@Mines HSPC 2023 > Advanced C번