Submission #3792191


Source Code Expand

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
bool solve();

signed main()
{
    int q;
    cin >> q;
    while (q--) {
        init();
        PRINT(solve());
    }
}

ll A, B, C, D;

void init()
{
    cin >> A >> B >> C >> D;
}

ll gc(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gc(y, x % y);
}

bool solve()
{
    if (A < B || D < B) {
        cerr << "A ";
        return false;
    }
    if (B-1 <= C) {
        cerr << "B ";
        return true;
    }
    ll X = A - C;
    ll cnt = (X + B - 1) / B;
    A -= cnt * B;
    if (A < 0) {
        cerr << "C ";
        return false;
    }
    if (D - B == 0) {
        cerr << "D ";
        return true;
    }
    X = (D - B) % B;
    ll G = gc(X, B);
    ll amari = A % G;
    if (amari <= C + 1 - B) {
        cerr << "E ";
        return false;
    }
    ll L = (C + 1) % G;
    ll R = (B - 1) % G;
    if (L <= R) {
        cerr << "F ";
        return !(L <= amari && amari <= R);
    } else {
        cerr << "G ";
        return (R < amari && amari < L);
    }
}

Submission Info

Submission Time
Task B - rng_10s
User spihill
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2018 Byte
Status WA
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 2
AC × 2
WA × 3
Set Name Test Cases
Sample example_0, example_1
All example_0, example_1, multi_0, multi_1, multi_2
Case Name Status Exec Time Memory
example_0 AC 1 ms 256 KB
example_1 AC 1 ms 256 KB
multi_0 WA 3 ms 256 KB
multi_1 WA 3 ms 256 KB
multi_2 WA 3 ms 256 KB