Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- ll n,k,a,b;
- ll get_ans(ll l){
- ll sz = 1LL * n * k;
- ll gcd = __gcd(l, sz);
- sz = sz / gcd;
- return sz;
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cin>>n>>k>>a>>b;
- ll x = 2e18;
- ll y = 0;
- for(ll l = b - a; l <= 2*n*k; l+=k){
- if(l<=0) continue;
- x = min(x, get_ans(l));
- y = max(y, get_ans(l));
- }
- for(ll l = a - b; l <= 2*n*k; l+=k){
- if(l<=0) continue;
- x = min(x, get_ans(l));
- y = max(y, get_ans(l));
- }
- for(ll l = a + b - k; l <= 2*n*k; l+=k){
- if(l<=0) continue;
- x = min(x, get_ans(l));
- y = max(y, get_ans(l));
- }
- for(ll l = - a - b; l <= 2*n*k; l+=k){
- if(l<=0) continue;
- x = min(x, get_ans(l));
- y = max(y, get_ans(l));
- }
- cout<<x<<" "<<y<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement