http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1006&cid=638
630 12
3 5*6*7 2 2*3Hint630 = 3*5*6*7
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <cmath> #include <cstdlib> #include <limits> #include <queue> #include <stack> #include <vector> #include <map> using namespace std; typedef long long LL; #define N 1100 #define INF 0x3f3f3f3f #define PI acos (-1.0) #define EPS 1e-8 #define met(a, b) memset (a, b, sizeof (a)) int val[N], ans[N], maxn; void DFS (int n, int m, int len) { if (n%m==0) { val[len] = m; DFS (n/m, m+1, len+1); } else if (maxn < len) { maxn = len; for (int i=0; i<len; i++) ans[i] = val[i]; } return; } int main () { int n; while (scanf ("%d", &n) != EOF) { met (val, 0); met (ans, 0); maxn = 0; int k = sqrt (n); for (int i=2; i<=k; i++) DFS (n, i, 0); if (!maxn) { maxn = 1; ans[0] = n; } printf ("%d\n", maxn); for (int i=0; i<maxn-1; i++) printf ("%d*", ans[i]); printf ("%d\n", ans[maxn-1]); } return 0; }