Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Dark_kingdom
Problemset: แยกตัวประกอบ
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-16 21:47:09
#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
if (!(cin >> n)) return 0;
bool first = true;
for (long long i = 2; i * i <= n; i++) {
if (n % i == 0) {
int count = 0;
while (n % i == 0) {
count++;
n /= i;
}
if (!first) cout << " ";
cout << i << "^" << count;
first = false;
}
}
if (n > 1) {
if (!first) cout << " ";
cout << n << "^1";
}
cout << "\n";
return 0;
}