작성일 :

문제 링크

17356번 - 욱 제

설명

두 능력치 A, B가 주어질 때 욱이 제를 이길 확률을 구하는 문제입니다.


접근법

M = (B - A) / 400으로 계산하고, 확률은 1 / (1 + 10^M)입니다.

공식을 그대로 실수로 계산하여 출력합니다.



Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
using System;

class Program {
  static void Main() {
    var line = Console.ReadLine()!.Split();
    var a = int.Parse(line[0]);
    var b = int.Parse(line[1]);
    var m = (b - a) / 400.0;
    var ans = 1.0 / (1.0 + Math.Pow(10.0, m));
    Console.WriteLine($"{ans:F4}");
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  double a, b; cin >> a >> b;
  double m = (b - a) / 400.0;
  double ans = 1.0 / (1.0 + pow(10.0, m));
  cout.setf(ios::fixed);
  cout.precision(4);
  cout << ans << "\n";

  return 0;
}