結果
| 問題 | 
                            No.148 試験監督(3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 21:31:51 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 723 bytes | 
| コンパイル時間 | 173 ms | 
| コンパイル使用メモリ | 81,968 KB | 
| 実行使用メモリ | 74,772 KB | 
| 最終ジャッジ日時 | 2025-06-12 21:32:51 | 
| 合計ジャッジ時間 | 4,580 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | TLE * 1 -- * 11 | 
ソースコード
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()
            
            
            
        
            
gew1fw