結果
問題 |
No.2324 Two Countries within UEC
|
ユーザー |
![]() |
提出日時 | 2023-06-06 18:43:23 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 620 ms / 2,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 138 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-06-26 23:37:04 |
合計ジャッジ時間 | 14,947 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - ans Syntax OK
ソースコード
N, M, P, Q = gets.split.map(&:to_i) ans = 0 Q.times do x, f = gets.split.map(&:to_i) if x % P == 0 if f == 0 puts M else puts 0 end else t = f * x.pow(P - 2, P) % P if t == 0 if P > M puts 0 else ok = 1 ng = M + 1 while (ok - ng).abs >= 2 k = (ok + ng) / 2 if P * k <= M ok = k else ng = k end end puts ok end else if t > M puts 0 else ok = 1 ng = M + 2 while (ok - ng).abs >= 2 k = (ok + ng) / 2 if P * (k - 1) + t <= M ok = k else ng = k end end puts ok end end end end