题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
#include <iostream> #include <math.h> using namespace std; class solution{ public: void component(int num){ int i = 2; while(true){ if (pow(num, 0.5) < i) { cout << num; break; } if(num % i == 0){ cout << i << ' '; num /= i; i = 2; } else{ i ++; } } cout << endl; } }; int main(){ solution sol; int num; cin >> num; sol.component(num); return 0; }