結果

問題 No.3133 法B逆元
ユーザー hato336
提出日時 2025-05-02 21:26:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,800 KB
実行使用メモリ 89,984 KB
最終ジャッジ日時 2025-05-02 21:26:36
合計ジャッジ時間 4,548 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
n,b = map(int,input().split())
if math.gcd(n,b) != 1:
    exit(print('NaN'))

z = 0
for i in range(1,b):
    if math.gcd(b,i) == 1:
        z += 1
print(pow(n,z-1,b))
0