题解 | #字符统计#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
不用sqrt就会超时
#include <cmath>
using namespace std;
int main()
{
long n;
cin >> n;
for (int i = 2; i <= sqrt(n);) {
if (n % i == 0) {
cout << i << " ";
n = n / i;
} else {
i++;
}
}
if (n != 1) //运行到最后自己就是质数时输出
cout << n << endl;
}