标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 626 Accepted Submission(s): 94
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <queue>
#include <algorithm>
using namespace std;
#define N 110000
int ans[100], a[100], K;
void DFS(int i, int n, int k)
{
if(n%i==0)
{
a[k] = i;
DFS(i+1, n/i, k+1);
}
else
{
if(k>K)
{
K = k;
for(int i=0; i<k; i++)
ans[i] = a[i];
}return ;
}
}
int main()
{
int n;
while(scanf("%d", &n)!=EOF)
{
int i, w = (int)sqrt(n);
K = 0;
for(i=2; i<=w; i++)
DFS(i, n, 0);
if(a[0]==0 || K==0)
{
printf("1\n%d\n", n);
}
else
{
printf("%d\n", K);
for(i=0; i<K; i++)
printf("%d%c", ans[i], i==K-1?‘\n‘:‘*‘);
}
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/YY56/p/5005198.html