結果

問題 No.1220 yukipoker
ユーザー 已经死了
提出日時 2025-03-03 00:58:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,364 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 114,740 KB
最終ジャッジ日時 2025-03-03 00:58:05
合計ジャッジ時間 3,849 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

def main():
    input = sys.stdin.read().split()
    Q = int(input[0])
    idx = 1
    for _ in range(Q):
        N = int(input[idx])
        M = int(input[idx+1])
        K = int(input[idx+2])
        idx +=3
        
        if K == 1:
            print("Flush" if 1 < 1 else "Straight")  # Unreachable due to problem constraints
            continue
        
        a = N - K + 2
        
        # Compute sum1: sum_{x=a}^N ln(x) ≈ integral from a-1 to N of ln(x) dx
        if a > N:
            sum1 = 0.0
        else:
            x_upper = N + 1
            integral_upper = x_upper * math.log(x_upper) - x_upper
            x_lower = a - 1
            if x_lower < 1:
                x_lower = 1
                integral_lower = 0.0
            else:
                integral_lower = x_lower * math.log(x_lower) - x_lower
            sum1 = integral_upper - integral_lower
        
        # Compute sum2: ln(K!) using Stirling's approximation
        if K == 0:
            sum2 = 0.0
        else:
            sum2 = K * math.log(K) - K + 0.5 * math.log(2 * math.pi * K)
        
        left_part = sum1 - sum2
        threshold = left_part / (K - 1)
        ln_M = math.log(M)
        
        if ln_M > threshold:
            print("Flush")
        else:
            print("Straight")

if __name__ == "__main__":
    main()
0