【題解】AtCoder ABC 169D – Div Game

【題目敘述】https://atcoder.jp/contests/abc169/tasks/abc169_d

#include <iostream>
#include <cmath>
using namespace std;

int ans;
long long n;

int main() {
    cin >> n;
    for (int i = 2; i <= sqrt(n); i++){
        if (n % i == 0){
            int cnt = 0;
            while (n % i == 0){
                n /= i;
                cnt++;
            }
            int tmp = 1;
            while (cnt >= tmp){
                cnt -= tmp;
                ans++;
                tmp++;
            }
        }
    }
    if (n != 1) ans++;
    cout << ans << "\n";
}
分享本文 Share with friends