結果
問題 |
No.3022 一元一次式 mod 1000000000
|
ユーザー |
![]() |
提出日時 | 2025-02-15 02:41:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 387 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,792 KB |
実行使用メモリ | 77,688 KB |
最終ジャッジ日時 | 2025-02-15 02:41:38 |
合計ジャッジ時間 | 2,960 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 1 |
ソースコード
import math T=int(input()) for _ in range(T): N,M=map(int, input().split()) p=10**9 g = math.gcd(N,M,10**9) N%=p M%=p if N==0 and M==0: print(1) continue elif N==0: print(-1) continue N//=g M//=g t=10**9//g if N%t==0 or math.gcd(N,t)>1: print(-1) else: a = -M*pow(N,-1,t)%t print(a)