题解 | #质数因子#

质数因子

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>

全部评论

相关推荐

牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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