全TLE求调
查看原帖
全TLE求调
1360496
NullPointerExpection楼主2024/7/20 15:28
#include <bits/stdc++.h>
using namespace std;

long long n;
bool first = true;
int main() {
	cin >> n;
	long long temp = n;
	for(int i = 2; i * i <= n; i++) {
		if(!(temp % i)) {
			int index = 0;
			while(!(temp % i)) {
				temp /= i;
				index++;
			}
			if(!first)
				cout << "* ";
			if(index > 1)
				cout << i << '^' << index << ' ';
			else
				cout << i << ' ';
			first = false;
		}
	}
	if(temp > 1) {
		if(temp == n)
			cout << temp;
		else
			cout << "* " << temp;
	}
	return 0;
}
2024/7/20 15:28
加载中...