結果
問題 |
No.3022 一元一次式 mod 1000000000
|
ユーザー |
![]() |
提出日時 | 2025-02-16 01:46:28 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 562 ms / 2,000 ms |
コード長 | 593 bytes |
コンパイル時間 | 131 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-02-17 12:58:47 |
合計ジャッジ時間 | 2,988 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
import sys input = sys.stdin.readline def p(x,m): ANS=0 while x%m==0: ANS+=1 x//=m return ANS T=int(input()) for tests in range(T): N,M=map(int,input().split()) N2=p(N,2) N5=p(N,5) M2=p(M,2) M5=p(M,5) if min(N2,9)<=M2 and min(N5,9)<=M5: pass else: print(-1) continue d=(2**min(N2,9))*(5**min(N5,9)) N//=d M//=d mod=10**9 mod//=d if mod==1: print(1) continue k=-M*pow(N,-1,mod)%mod if k==0: print(mod) else: print(k)