题解 | 质数因子-构思
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
#include <iostream> #include <cmath> using namespace std; int main(){ long input; cin >> input; int a = 2; while(input != 1) { if(a>sqrt(input)) { cout << input << " "; break; } while (input % a==0) { cout << a << " "; input /=a; } a++; } return 0; }