11 9412
11 2*2*13*181
//============================================================================
// Name : Math_hdu1164.cpp
// Author : vit
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
//start
#define MAX 65536
bool Visit[MAX];
int prime[MAX];
int p = 0;
void Prime()//可做求质数的模板
{
memset(Visit,true,sizeof(Visit));
Visit[0] = Visit[1] = 0;
for(int i = 2; i < MAX; ++i)
{
if(Visit[i])
{
prime[p] = i;
p++;
for(int j = i; j < MAX; j+=i)
Visit[j] = false;
}
}
}
//end
int main() {
int i;
int n;
Prime();
while(cin >> i){
if(Visit[i])
printf("%d\n",i);
else{
n = 0;
while(i != 1){
if(i % prime[n] == 0){
cout << prime[n];
i = i / prime[n];
if(i != 1)
cout << "*";
}
else
n++;
}
cout << endl;
}
}
return 0;
}
hdu1164 Eddy's research I,布布扣,bubuko.com
原文:http://blog.csdn.net/svitter/article/details/22996463