본문 바로가기

Algorithm/Implementation

(C++) - 백준(BOJ) 24751 : Betting

반응형

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

간단한 소수점 출력문제였습니다.

📕 풀이방법

📔 입력 및 초기화

optionOne을 선언 후 입력받습니다.

📔 풀이과정

option 1의 배팅률은 100 / optionOne이며 

option 2의 배팅률은 100 / (100 - optionOne) 입니다.

📔 정답출력

상대오차에 맞춰 출력합니다.


📕 Code

#include <bits/stdc++.h>
using namespace std;
double optionOne;
int main(){
  cin >> optionOne;
  printf("%.10f\n%.10f", 100 / optionOne, 100 / (100 - optionOne));
}