結果

問題 No.3133 法B逆元
コンテスト
ユーザー tomerun
提出日時 2025-05-02 21:25:40
言語 Crystal
(1.19.1)
コンパイル:
crystal build -Donline_judge -o a.out --release --no-debug _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 192 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,725 ms
コンパイル使用メモリ 338,836 KB
実行使用メモリ 9,332 KB
最終ジャッジ日時 2026-07-10 10:43:15
合計ジャッジ時間 8,862 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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