Skip to content

Commit 5a08d8e

Browse files
committed
CT_408
1 parent 3d9e2d9 commit 5a08d8e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package B1
2+
3+
fun main() {
4+
readLine()
5+
val sumA = readLine()!!.split(" ").map { it.toInt() }.sum()
6+
val sumB = readLine()!!.split(" ").map { it.toInt() }.sum()
7+
8+
val g = gcd(sumA, sumB) // 최대공약수 계산
9+
val a = sumB / g
10+
val b = sumA / g
11+
12+
println("$a $b")
13+
}
14+
15+
fun gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)

0 commit comments

Comments
 (0)