Kotlin/Kotlin 알고리즘

백준 24751번 Betting Kotlin 구현해보기

kimc 2022. 9. 15. 19:20

```

백준 24751번 Betting Kotlin 구현해보기

```

Kimc Kotlin Study

이번 글을 통해 배워갈 내용

  1. 백준 24751번 풀이

https://www.acmicpc.net/problem/24751

 

24751번: Betting

For each option (option one, then option two), display the number x such that 1:x is the switch-payout-ratio for that option. Your answer should have an absolute or relative error of at most $10^{-3}$.

www.acmicpc.net

 

백준 24751번 Betting은

 

난이도 브론즈 등급의 문제로서

 

전체 확률 100프로 중

이 길 확률이 주어지면

질 확률과 이 길 확률에 이길 때 받는 switch point를 계산해주면 됩니다.

 

예를 들어

승률이 60프로라면

받는 비율은 약 100/60 = 1.66666666667입니다

 


30분 정도 위에 링크를 방문하셔서 풀어보시고

안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.


입력을 받고

정해진 조건에 맞춰서 계산을 해서 출력해주면 되는

문제입니다.

 

fun main(args: Array<String>) {
    // 입력

    // 이길 확률 possibility of winning
    val winPos = readln().toInt()

    // 질 확률 possibility of losing
    val losPos = 100 - winPos

    // 출력
    print("${100.0 / winPos}\n${100.0 / losPos}")
}


// https://codemasterkimc.tistory.com/

 

 

읽어주셔서 감사합니다

 

무엇인가 얻어가셨기를 바라며

 

오늘도 즐거운 코딩 하시길 바랍니다 ~ :)

 


 

728x90