結果

問題 No.148 試験監督(3)
ユーザー gew1fw
提出日時 2025-06-12 16:53:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 723 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 74,604 KB
最終ジャッジ日時 2025-06-12 16:53:55
合計ジャッジ時間 4,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 2 -- * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    T = int(data[0])
    idx = 1
    for _ in range(T):
        C = int(data[idx])
        idx += 1
        P = int(data[idx])
        idx += 1
        
        if C < P:
            print(0)
            continue
        
        twoP_minus1 = 2 * P - 1
        if C < twoP_minus1:
            print(0)
            continue
        
        A = C - 2 * P + 2
        B = C - P + 1
        
        if B >= MOD:
            print(0)
        else:
            product = 1
            for x in range(A, B + 1):
                product = (product * x) % MOD
            print(product % MOD)

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