#24405:


fire5386 (becaidorz)

學校 : 國立清華大學
編號 : 115822
來源 : [140.114.253.147]
最後登入時間 :
2024-10-03 15:39:22
d418. 00993 - Product of digits -- UVa993 | From: [61.230.3.179] | 發表日期 : 2021-02-14 21:44

如果n=1,直接輸出1

否則

對n做9~2的因數分解(從9開始因為9<33、8<222)

分解完後如果n不等於1,代表n無法變成以2~9的數字組成的數字

否則把剛剛分解的順數顛倒輸出就好了

範例:

216

216 % 9 = 0, list = "9", n = 24

24 % 9 != 0, list = "9", n = 24

24 % 8 = 0, list = "9, 8", n = 3

3 % 8 != 0, list = "9, 8", n = 3

3 % 7 != 0, list = "9, 8", n = 3

3 % 6 != 0, list = "9, 8", n = 3

3 % 5 != 0, list = "9, 8", n = 3

3 % 4 != 0, list = "9, 8", n = 3

3 % 3 = 0, list = "9, 8, 3", n = 1

1 % 3 != 0, list = "9, 8, 3", n = 1

1 % 2 = 0, list = "9, 8, 3", n = 1

完畢,n = 1,代表有辦法表示,其中最小符合的就是list顛倒後的389

 
ZeroJudge Forum