解法一
✅ 完整代碼
評分結果(參考) : AC (4ms, 316KB)
#include <bits/stdc++.h>
using namespace std;
int f(int x){
int sum = 0;
int i = 2;
while(i <= sqrt(x)){
if(x%i == 0){
x /= i;
sum += i;
}
else i++;
}
return sum + x;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x;
while(cin >> x) cout << f(x) << "\n";
return 0;
}