結果

問題 No.1220 yukipoker
ユーザー lam6er
提出日時 2025-03-20 20:22:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,880 KB
実行使用メモリ 113,960 KB
最終ジャッジ日時 2025-03-20 20:24:18
合計ジャッジ時間 3,316 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

def stirling_ln_fact(n):
    if n == 0:
        return 0.0
    return n * math.log(n) - n + 0.5 * math.log(2 * math.pi * n)

def main():
    input = sys.stdin.read().split()
    idx = 0
    Q = int(input[idx])
    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("Straight")
            continue
        
        # Compute the three terms in Stirling's approximation
        ln_N = stirling_ln_fact(N)
        ln_K1 = stirling_ln_fact(K-1)
        ln_NK1 = stirling_ln_fact(N - K + 1)
        
        log_C_approx = ln_N - ln_K1 - ln_NK1
        
        log_K = math.log(K)
        log_M_terms = (K-1) * math.log(M)
        term = log_C_approx - log_K - log_M_terms
        
        if term > 1e-12:
            print("Straight")
        else:
            print("Flush")

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