UVA-993 - Product of Digits

  • UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt
  • 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
  • 本題選為「20170328 大學程式能力檢定 CPE」題目。
  • 相同題目:ZOJ-d418

題意概要

給你一個大於等於 的整數 ,請你你找到最小的自然數 ,使得在 中所有數字(digit)的乘積等於


Input

The first line of input contains one positive integer number, which is the number of data sets. Each subsequent line contains one data set which consists of one non-negative integer number ().


Output

For each data set, write one line containing the corresponding natural number or -1 if does not exist.


Sample Input

3
1
10
123456789

Sample Output

1
25
-1
profile-image
David Lu
Hello, I'm David Lu. I am a graduate student in Department of Computer Science at National Chiao Tung University, Taiwan. I am in the Networking and Sensing Systems (NSS) Lab at NCTU. If you have any question, please feel free to contact with me.
comments powered by Disqus