結果

問題 No.3133 法B逆元
ユーザー tomerun
提出日時 2025-05-02 21:25:40
言語 Crystal
(1.14.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 192 bytes
コンパイル時間 16,589 ms
コンパイル使用メモリ 308,696 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-02 21:25:59
合計ジャッジ時間 11,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n, b = read_line.split.map(&.to_u64)
if b == 1
  puts 0
  exit
end
if n == 0 || n.gcd(b) != 1
  puts "NaN"
  exit
end
n %= b
1.upto(b) do |i|
  if n * i % b == 1
    puts i
    exit
  end
end
0