题解 | #质数因子#

质数因子

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>

全部评论

相关推荐

昨天 14:14
门头沟学院 Java
7.10投递7.15感谢信
投递地平线等公司7个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务