a = 끝말잇기에 걸리는 시간 (분)
d = 끝말잇기에 이길 확률
k = 오른 승률
solve = 이길 확률을 넣었을 때 걸리는 시간을 반환하는 함수
1. 끝말잇기에 이길 확률을 넣음
-> 만약 확률이 100이면 (1이면) a분을 반환
2. 이길 확률 * a분 + 질 확률 * (다음에 이길 확률의 시간 값) + a분
이번에 이길 확률에 시간 곱한거라 졌을 때 걸리는 시간 두 개 더하면 시간의 기댓값이 나온다.
졌을 때 걸리는 시간은 일단 졌으니 a분을 더해야 하고 다음번에 이겼을 때의 시간을 더해준다.
아 이런 왜이리 죽을것 같은 기분이 드냐 했더니 점심을 안 먹었다. 밥 먹고 마저 품
풀었다
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#include <stdio.h>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using iis = pair<int, string>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
double a, d, k;
double solve(double d) {
if (d >= 100)
return a;
double res = d * 0.01 * a + (100 - d) * 0.01 * (a + solve(d * (1 + k * 0.01)));
return res;
}
int main() {
scanf("%lf %lf %lf", &a, &d, &k);
printf("%.10lf", solve(d));
return 0;
}
'UCPC' 카테고리의 다른 글
UCPC 2021 본선 후기 (0) | 2021.08.14 |
---|---|
22358 스키장 (0) | 2021.08.01 |
22351 수학은 체육과목 입니다 3 (0) | 2021.08.01 |
UCPC 2021 예선 후기 (6) | 2021.08.01 |
UCPC 2020 후기 (0) | 2020.08.01 |