結果
問題 | No.3022 一元一次式 mod 1000000000 |
ユーザー |
|
提出日時 | 2025-02-15 09:29:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 488 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 268 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 79,240 KB |
最終ジャッジ日時 | 2025-02-17 12:58:32 |
合計ジャッジ時間 | 3,232 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
def main():t = int(input())for _ in range(t):n, m = map(int, input().split())cntn1 = cntn2 = cntm1 = cntm2 = 0x = nwhile x%2==0:x //= 2cntn1 += 1while x%5==0:x //= 5cntn2 += 1x = mwhile x%2==0:cntm1 += 1x //= 2while x%5==0:x //= 5cntm2 += 1if min(cntn1, 9) > cntm1 or min(cntn2, 9) > cntm2:print("-1")continuediv = (1<<min(cntn1, 9))*pow(5, min(cntn2, 9))x = n//divy = m//divmodulo = 1000000000//divinv = pow(x, -1, modulo)res = (modulo-y*inv%modulo)%moduloprint(res if res else modulo)if __name__ == "__main__":main()