結果

問題 No.2324 Two Countries within UEC
ユーザー i39
提出日時 2023-05-29 17:01:54
言語 Ruby
(3.4.1)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 203 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-06-26 23:33:16
合計ジャッジ時間 11,895 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n,m,p,q=gets.split.map(&:to_i)
q.times do
  x,f=gets.split.map(&:to_i)
  if x%p==0 then
    puts (f==0 ? m : 0)
  elsif f==0 then
    puts m/p
  else
    y=(f*x.pow(p-2,p))%p
    puts (m-y)/p+1
  end
end
0