2016-05-19 Problem Solving►UVa UVa 993 - Product of digits Contents 1. Problem2. Solution3. Code Problem題目網址中文網址 Solutiongreedy,從 9 開始遞減,只要可以整除 n ,就加進答案內 。最後再從小的開始輸出即可。 CodeUVa 993UVa 993 - Product of digits12345678910111213141516171819202122232425262728293031323334353637383940#include<stdio.h>int main(){ int Case; scanf("%d", &Case); while (Case--) { int n; scanf("%d", &n); if (n == 1) { puts("1"); continue; } int num[10] = { 0, 1 }, i, j; for (i = 9; n > 1 && i > 1; --i) { while (!(n%i)) { ++num[i]; n /= i; } } if (n != 1) puts("-1"); else { for (i = 2; i < 10; i++) for (j = 0; j < num[i]; j++) putchar('0' + i); putchar('\n'); } } return 0;} Newer UVa 10003 - Cutting Sticks Older ZeroJudge b309 - 聖杯戰爭