1 solutions
-
0
#include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; long long p, q; cin >> n >> p >> q; while (n--) { long long a, b; cin >> a >> b; if (a == b) { cout << "0\n"; continue; } long long g = __gcd(a, b); if (p <= q) { if (g == 1) { cout << p << "\n"; } else { cout << min(q, 2 * p) << "\n"; } } else { // p > q if (g == 1) { cout << min(p, 2 * q) << "\n"; } else { cout << q << "\n"; } } } return 0; }超级解析,你!值得拥有!
Information
- ID
- 2898
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- # Submissions
- 5
- Accepted
- 1
- Uploaded By