PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000017. Bậc chia hết cho 9 (2 the 9s)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bậc chia hết cho 9 (2 the 9s)
2 the 9s
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive decimal integer as a string, determine whether it is divisible by . If so, compute its 9-degree: the number of successive digit-sum checks needed to reach a single digit , counting as degree .
Input
One line contains positive decimal string different from 0.
Output
If divisible, print N is a multiple of 9 and has 9-degree D.; otherwise N is not a multiple of 9..
Subtasks
- Subtask 1 (20 points):
- Subtask 2 (30 points):
- Subtask 3 (50 points): ; The string represents a positive decimal integer.
Examples
Input
999
Output
999 is a multiple of 9 and has 9-degree 2.
Explanation
Digit sums are and then , so the degree is .