結果
問題 |
No.2324 Two Countries within UEC
|
ユーザー |
![]() |
提出日時 | 2023-06-15 17:01:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 251 ms / 2,000 ms |
コード長 | 483 bytes |
コンパイル時間 | 1,834 ms |
コンパイル使用メモリ | 170,724 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 23:38:29 |
合計ジャッジ時間 | 8,574 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/math> using namespace atcoder; int main() { int N, M, P, Q; cin >> N >> M >> P >> Q; for( int i = 0; i < Q; i++ ) { long long x, f; cin >> x >> f; if( x % P == 0 ) { int ans = 0; if( f == 0 ) ans = M; cout << ans << endl; } else { long long ix = inv_mod( x, P ); long long y = f * ix % P; int ans = (M - y) / P; if( y ) ans++; if( y > M ) ans = 0; cout << ans << endl; } } }