import java.util.*
import kotlin.math.*
fun main() = with(Scanner(System.`in`)) {
// 코틀린 제곱을 사용하려고 했는데 아직 어려워서 java 제곱을 썻다.
// Math.pow(doulbe, double)
var ans = (Math.pow(nextDouble(),2.0) + Math.pow(nextDouble(),2.0)
+ Math.pow(nextDouble(),2.0) + Math.pow(nextDouble(),2.0)
+ Math.pow(nextDouble(),2.0))%10
println(ans.toInt()) // 출력값이 double형 이라서 Int로 고쳐주었다.
}

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
|
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import kotlin.math.pow
val br = BufferedReader(InputStreamReader(System.`in`))
fun main()=with(br){
val bw = BufferedWriter(OutputStreamWriter(System.out))
val list = readLine()!!.split(" ").map{it.toDouble()}
var sum = 0.0
for(i in list.indices){
sum+=list[i].pow(2)
}
sum %= 10
bw.write("${sum.toInt()}")
bw.flush()
bw.close()
}
|
cs |
'알고리즘 공부 > 미분류' 카테고리의 다른 글
10950번 kotlin (0) | 2021.07.04 |
---|---|
백준 1271 Kotlin #BigInteger ★ (0) | 2021.07.04 |
2845번 Kotlin (0) | 2021.07.03 |
백준 1008번 코틀린 ★ (0) | 2021.06.30 |
백준 1000번 코틀린으로 풀어보기. ☆ (0) | 2021.06.30 |