結果
| 問題 | No.148 試験監督(3) |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:46:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 955 bytes |
| 記録 | |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 82,636 KB |
| 実行使用メモリ | 67,856 KB |
| 最終ジャッジ日時 | 2025-03-31 17:47:12 |
| 合計ジャッジ時間 | 4,908 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 11 |
ソースコード
MOD = 10**9 + 7
def compare_strings(a, b):
if len(a) > len(b):
return True
elif len(a) < len(b):
return False
else:
return a >= b
def mod_num(s, mod):
result = 0
for c in s:
result = (result * 10 + int(c)) % mod
return result
T = int(input())
for _ in range(T):
c_str, p_str = input().split()
# Check if P >= MOD (quick check based on string length)
if len(p_str) > 10:
print(0)
continue
p_int = int(p_str)
if p_int >= MOD:
print(0)
continue
# Compute 2*p_int - 1
q_int = 2 * p_int - 1
q_str = str(q_int)
# Check if C >= q_str
if not compare_strings(c_str, q_str):
print(0)
continue
# Calculate c_mod and compute the product
c_mod = mod_num(c_str, MOD)
product = 1
for k in range(p_int):
term = (c_mod - p_int + 1 - k) % MOD
product = (product * term) % MOD
print(product)
lam6er