結果

問題 No.3133 法B逆元
ユーザー Raj Nangare
提出日時 2025-05-02 22:28:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 212 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-05-02 22:28:08
合計ジャッジ時間 3,589 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n, b = map(int,input().split())


ans = -1

for i in range(min(n + 1, b + 1)):
    if (n * i ) % b == 1:
        ans = i
        break
if b == 1:
    print(0)
elif ans == -1:
    print("NaN")
else:
    print(ans)
0