forked from anandadfoxx/codeforces_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1294C.cpp
37 lines (33 loc) · 879 Bytes
/
1294C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
#define FOR(i, start, end) for(int i = start; i < end; i++)
using namespace std;
typedef long long LL;
void solve() {
int n;
scanf("%d", &n);
int fact[3] = {-1, -1, -1}, factIdx = 0;
for (int i = 2; i <= sqrt((double)n)+1 && factIdx < 3; i++) {
if (n % i == 0) {
if (factIdx == 0) fact[factIdx] = i;
else if (n / i != fact[factIdx-1]) fact[factIdx] = i;
else break;
n /= i;
factIdx++;
if (factIdx == 2 && n != fact[factIdx-1]) {
fact[factIdx] = n;
factIdx++;
}
}
}
if (factIdx >= 3) {
printf("YES\n");
FOR(i, 0, 3)
printf((i != 2) ? "%d " : "%d\n", fact[i]);
}
else printf("NO\n");
}
int main() {
short t;
scanf("%hd", &t);
while (t--) solve();
}