We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3d9e2d9 commit 5a08d8eCopy full SHA for 5a08d8e
BOJ/Kotlin/src/B1/Boj_31473_하늘과핑크.kt
@@ -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