a178: 10922 - 2 the 9s
Tags : 遞歸 數學
Accepted rate : 45人/50人 ( 90% ) [非即時]
評分方式:
Tolerant

最近更新 : 2020-10-19 12:36

Content

我們知道要怎麼確定一個整數是不是 9 的倍數-如果它每位數的總和是9的倍數,那它就是9的倍數。這種檢驗的方法其實是一種遞迴的方法,而且我們把這種方法遞迴的深度稱作 N 的 9-degree 。

你的工作就是,給你一個正整數N,判斷他是不是9的倍數,而且如果他是9的倍數你還需要判斷它的 9-degree。

Input

輸入含有多組測試資料。每組測試資料一列包含一個正數 N。

當 N=0 時代表輸入結束;輸入的數最大可以到1000位數。

Output

對於每一組測試資料,請輸出它是否是 9 的倍數及它的 9-degree。輸出格式請參考Sample Output。

Sample Input #1
999999999999999999999
9
9999999999999999999999999999998
837
0
Sample Output #1
999999999999999999999 is a multiple of 9 and has 9-degree 3.
9 is a multiple of 9 and has 9-degree 1.
9999999999999999999999999999998 is not a multiple of 9.
837 is a multiple of 9 and has 9-degree 2.
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 1.0s , <1K
Hint :
Tags:
遞歸 數學
出處:
UVa10922 [管理者:
zero (管理員)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」