Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 626 Accepted Submission(s): 94
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<map> using namespace std; const int INF = 1e9+7; int a[100],Max=0,b[100]; void dfn(int n,int k,int l) { if(n%k==0 && n!=1) { a[l]=k; dfn(n/k,k+1,l+1); } else if(Max<l) { Max=l; for(int i=0;i<l;i++) { b[i]=a[i]; } } } int main() { int n; while(scanf("%d",&n)!=EOF) { int len=sqrt(n); Max=0; for(int i=2;i<=len;i++) { dfn(n,i,0); } if(Max==0 && n!=1) { Max=1; b[0]=n; } printf("%d\n",Max); printf("%d",b[0]); for(int i=1;i<Max;i++) { printf("*%d",b[i]); } printf("\n"); } return 0; }
原文:http://www.cnblogs.com/linliu/p/5005297.html