Submission #2849252


Source Code Expand

Copy
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}

bool solve(ll A, ll B, ll C, ll D) {
  if (B > D) return false;

  ll x = max(A - C - 1, 0LL);
  ll t = x / B;
  ll a = A - t * B;
  if (a - B < 0) return false;

  if (B <= C) return true;

  ll g = gcd(B, D);
  return B - g + A % g <= C;
}

int main(void) {
  ll T;
  cin >> T;

  while (T-- > 0) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (solve(A, B, C, D) ? "Yes" : "No") << endl;
  }
}

Submission Info

Submission Time
Task B - rng_10s
User kshinya
Language C++14 (GCC 5.4.1)
Score 600
Code Size 634 Byte
Status
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
× 2
× 5
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 1 ms 256 KB
example_1 1 ms 256 KB
multi_0 2 ms 256 KB
multi_1 2 ms 256 KB
multi_2 2 ms 256 KB