题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
include
include
include
include
include
include <math.h>
using namespace std;
int main()
{
long input;
cin >> input;
vector<string> ret;
long tmp = 2;
string str = "";
while (input != 1)
{
if (input % tmp == 0)
{
input /= tmp;
str = to_string(tmp) + " ";
ret.push_back(str);
tmp = 2;
}
else
{
if(tmp>1000)
{
str = to_string(input) + " ";
ret.push_back(str);
break;
}
++tmp;
}
}
for (int i = 0; i < ret.size(); ++i)
{
cout << ret[i];
}
return 0;
}</string>