#2482: ans(c++)


1752786-4@g.puiching.edu.mo (林敬晉P5A08(JalenLam_progamer)(IQ...)

School : Pui Ching Middle School
ID : 3260
IP address : [192.168.120.33]
Last Login :
2025-06-05 11:37:15
a567. 分解質因數 | From: [192.168.120.33] | Post Date : 2025-06-09 15:21

#include <bits/stdc++.h>

using namespace std;

int main() {

    int N;

    cin >> N;

    cout << N << " = ";

    int originalN = N;

    while (N % 2 == 0) {

        cout << 2;

        N /= 2;

        if (N > 1) cout << " * ";

    }

    for (int i = 3; i * i <= N; i += 2) {

        while (N % i == 0) {

            cout << i;

            N /= i;

            if (N > 1) cout << " * ";

        }

    }

    if (N > 2) {

        cout << N;

    }

    cout << endl;

    return 0;

}

// JalenLam_progamer              Jalenpro             IQ380

// it is not real

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

// it is not real

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

// it is real

 
ZeroJudge Forum