結果

問題 No.3001 ヘビ文字列
ユーザー qwewe
提出日時 2025-05-14 12:56:17
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,674 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 82,052 KB
実行使用メモリ 89,344 KB
最終ジャッジ日時 2025-05-14 12:58:44
合計ジャッジ時間 31,668 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 83
権限があれば一括ダウンロードができます

ソースコード

diff #

# Import the sys module to interact with standard input/output.
import sys

# Define a function to encapsulate the problem-solving logic.
def solve():
    # Read a line from standard input and split it into parts based on whitespace.
    line = sys.stdin.readline().split()
    
    # Convert the first part to a float, representing probability X (P(1st child male)).
    X = float(line[0]) 
    # Convert the second part to a float, representing probability Y (P(2nd child male)).
    Y = float(line[1]) 
    
    # Calculate the minimum possible probability for P(1st child male AND 2nd child female).
    # Let M1 = "1st child male", F2 = "2nd child female".
    # P(M1) = X, P(F2) = 1 - Y.
    # Using Fréchet lower bound: max(0, P(M1) + P(F2) - 1)
    # Substituting: max(0.0, X + (1.0 - Y) - 1.0) = max(0.0, X - Y).
    # Python's built-in max() function works correctly with floats.
    min_prob = max(0.0, X - Y)
    
    # Calculate the maximum possible probability for P(1st child male AND 2nd child female).
    # Using Fréchet upper bound: min(P(M1), P(F2))
    # Substituting: min(X, 1.0 - Y).
    # Python's built-in min() function works correctly with floats.
    max_prob = min(X, 1.0 - Y)
    
    # Print the maximum and minimum probabilities to standard output.
    # The problem specifies outputting the maximum value first, then the minimum value, space-separated.
    # Use an f-string with format specifier ':.10f' to ensure fixed-point notation
    # with exactly 10 decimal places, meeting the required absolute error tolerance of 10^-9.
    print(f"{max_prob:.10f} {min_prob:.10f}")

# Execute the solve function to run the program logic.
solve()
0