-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.kt
40 lines (36 loc) · 1 KB
/
C.kt
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
38
39
40
import kotlin.math.sqrt
fun main() {
val input = System.`in`.bufferedReader()
val output = StringBuilder()
val t = input.readLine()!!.toInt()
repeat(t) {
var n = input.readLine()!!.toInt()
var copy = n
val primeFactors = mutableListOf<Int>()
var first = -1
for(i in 2..sqrt(n.toDouble()).toInt()) {
if(n % i == 0) {
first = i
break
}
}
if(first != -1) {
n /= first
var second = -1
for(i in 2..sqrt(n.toDouble()).toInt()) {
if(n % i == 0 && i > first && n / i > first && n / i > i) {
second = i
break
}
}
if(second != -1) {
output.append("YES\n$first $second ${copy / (first * second)}\n")
} else {
output.append("NO\n")
}
} else {
output.append("NO\n")
}
}
print(output)
}