text
stringlengths 49
983k
|
|---|
#include <iostream>
using namespace std;
typedef long long ll;
ll T,A,B,C,D;
ll gcd(ll a,ll b){
if(a%b==0) return b;
else return gcd(b,a%b);
}
int main(){
cin >> T;
for(int i=0;i<T;i++){
cin >> A >> B >> C >> D;
if(A<B) cout << "No" << endl;
else if(D<B) cout << "No" << endl;
else if(B<=C) cout << "Yes" << endl;
else{
ll g = gcd(B,D);
if(B-g+(A%g)<=C) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
}
|
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
LL gcd(LL a,LL b)
{
LL tmp;
while(b)
{
tmp=a;
a=b,b=tmp%b;
}
return a;
}
int main()
{
LL A,B,C,D;
int tm;
scanf("%d",&tm);
while(tm--)
{
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
bool f=1;
if(A<B) f=0;
else if(D<B) f=0;
else if(C>=B-1);
else
{
LL E=gcd(B,D);
if((A-B)/E<(A-C-1)/E) f=0;
}
if(f) printf("Yes\n");
else printf("No\n");
}
}
|
#include <cstdio>
typedef long long int64;
int64 gcd(const int64 x, const int64 y) { return y ? gcd(y, x % y) : x; }
int main() {
int T;
int64 A, B, C, D, g;
scanf("%d", &T);
while(T) {
T--;
scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
if(B > A or B > D)
printf("No\n");
else if(C >= B)
printf("Yes\n");
else {
g = gcd(B, D);
if(B - g + A % B % g > C)
printf("No\n");
else
printf("Yes\n");
}
}
return 0;
}
|
# include "cstdio"
# include "iostream"
using namespace std;
long long GCD(long long x,long long y){
return y==0?x:GCD(y,x%y);
}
int main(){
int t;
scanf("%d",&t);
while(t--){
long long a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b || b>d){
puts("No");
}else if(b<=c){
puts("Yes");
}else{
long long gcd=GCD(b,d);
if(b-gcd+a%gcd>c){
puts("No");
}else{
puts("Yes");
}
}
}
return 0;
}
|
#include<cstdio>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
bool chk(long long A,long long B,long long C,long long D){
if(B>A||D<B)return 0;
long long g=gcd(B,D),t=A+B-C-1;
if(t<0&&t%g!=0)t=t/g-1;
else t/=g;
return A-g*t>=0;
}
int main(){
int T;scanf("%d",&T);
while(T--){
long long A,B,C,D;
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
puts(chk(A,B,C,D)?"Yes":"No");
}
}
|
#include <cstdio>
#include <iostream>
#define ll long long
int t;
ll a,b,c,d;
ll gcd(ll x,ll y) {return y == 0 ? x : gcd(y, x%y);
}
int main() {
std :: cin >> t;
while(std :: cin >> a >> b >> c >> d){
ll g=gcd(b,d);
if(a<b || b>d || ((a-c-1ll)/g-(a-b)/g>0)) puts("No");
else puts("Yes");
}
}
|
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll a, b, c, d;
ll gcd(ll x, ll y) {
if(x % y == 0) return y;
else return gcd(y, x % y);
}
bool chk(ll A, ll B, ll C, ll D) {
if(A < B || D < B) return 0;
if(C + 1 >= B) return 1;
ll tmp = gcd(B, D);
A %= tmp;
return B - tmp + A <= C;
}
int main() {
cin >> n;
while(n--) {
cin >> a >> b >> c >> d;
if(chk(a, b, c, d)) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
|
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int T;
ll A, B, C, D;
ll gcd(ll a, ll b) {
return !b ? a : gcd(b, a % b);
}
int main() {
scanf("%d", &T);
while(T--) {
scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
ll g = gcd(B, D);
if(A < B || B > D || B - g + A % g > C) puts("No"); else puts("Yes");
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int ttt;
cin >> ttt;
while (ttt--) {
long long a, b, c, d;
cin >> a >> b >> c >> d;
if (a < b || d < b) {
cout << "No" << endl;
continue;
}
long long g = gcd(b, d);
g = g - a % g;
if (b - g > c) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
long long mygcd(long long a,long long b)
{
return b?mygcd(b,a%b):a;
}
void mokou()
{
long long a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b || d<b)
{
puts("No");
return;
}
a%=b;
if(c>=b-1)
{
puts("Yes");
return;
}
long long e=mygcd(b,d);
//cout<<a<<" "<<b<<" "<<c<<" "<<e<<endl;
puts((b-a-1)/e==(c-a)/e && a<=c?"Yes":"No");
}
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
mokou();
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
#define i64 long long int
i64 gcd(i64 x,i64 y){
return y?gcd(y,x%y):x;
}
bool chk(){
i64 A,B,C,D;
cin >> A >> B >> C >> D;
if(D<B || A<B)return false;
if(C>=B-1)return true;
i64 g=gcd(B,D);
A%=g;
return B-g+A <= C;
}
int main(){
int _;
for(cin >> _; _--;){
cout << (chk()? "Yes" :"No") << endl;
}
return 0;
}
|
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
LL gcd(LL x,LL y)
{
return x%y==0?y:gcd(y,x%y);
}
int main()
{
int i,j,k,n;
LL a,b,c,d;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b||d<b||c<a%b||c<b-gcd(b,d))
printf("No\n");
else
printf("Yes\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
while (b) {
long long c = a % b;
a = b;
b = c;
}
return a;
}
int main() {
int T;
ignore = scanf("%d", &T);
while (T--) {
long long a, b, c, d;
ignore = scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
bool ok = (a >= b) && (d >= b);
long long g = gcd(b, d);
a %= b;
long long x = a + (b - 1 - a) / g * g;
printf("%s\n", ok && x <= c ? "Yes" : "No");
}
return 0;
}
|
#include <iostream>
using namespace std;
#define int long long
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a%b);
}
signed main() {
int T;
cin >> T;
while (T--) {
int A, B, C, D;
cin >> A >> B >> C >> D;
if (A < B || D < B) {
cout << "No" << endl;
} else if (C < B - (gcd(B, D) - A % gcd(B, D))) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a,long long b){
for(long long r;b;) r=a%b,a=b,b=r;
return a;
}
inline bool jud(long long A,long long B,long long C,long long D){
if(A<B || D<B) return false;
if(C>=B) return true;
long long g=gcd(B,D);
return B-g+A%g<=C;
}
int main(){
int T;
scanf("%d",&T);
while(T--){
long long A,B,C,D;
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
puts(jud(A,B,C,D) ? "Yes":"No");
}
return 0;
}
|
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;
int gcd(int a,int b){
if(a<b)gcd(b,a);
int r;
while((r=a%b)){
a=b;
b=r;
}
return b;
}
signed main(){
int t;
cin>>t;
for(int i=0;i<t;i++){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(b>a||b>d){
cout<<"No"<<endl;
}else if(c>=b){
cout<<"Yes"<<endl;
}else{
int g=gcd(b,d);
if(b-g+(a%g)>c){
cout<<"No"<<endl;
}else{
cout<<"Yes"<<endl;
}
}
}
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
bool solve() {
long long a, b, c, d; cin >> a >> b >> c >> d;
if (a < b) return false;
if (d < b) return false;
long long g = gcd(b, d);
long long rem = a % g;
long long mi = (c - rem + g) / g * g + rem;
return mi >= b;
}
int main() {
int T; cin >> T;
while (T--) {
cout << (solve() ? "Yes" : "No") << endl;
}
return 0;
}
|
#include<iostream>
#include<algorithm>
using namespace std;
template<typename T>
T gcd(T a,T b){return b==0?a:gcd(b,a%b);}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(;0<T;T--)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
return 0;
}
|
#include<stdio.h>
typedef long long ll;
ll gcd(ll a,ll b){return a%b==0?b:gcd(b,a%b);}
ll adj(ll a,ll b,ll m){
if((a%m+m)%m>b)b+=m;
return a+b-(a%m+m)%m;
}
bool work(){
ll a,b,c,d,g;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(b>a||b>d)return 0;
g=gcd(b,d);
return adj(c-b+1,a%g,g)>=0;
}
int main(){
int T;
scanf("%d",&T);
while(T--)puts(work()?"Yes":"No");
}
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll x, ll y) {
if(y==0)return x;
return gcd(y,x%y);
}
int main(){
int n;cin>>n;
for(int i=0;i<n;++i){
bool pos=true;
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll g=gcd(b,d);
ll Max_Stock=b-g+a%g;
if(Max_Stock>c)pos=false;
if(a<b||d<b)pos=false;
if(pos)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b) {
for (; b; swap(a, b))
a %= b;
return a;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
long a, b, c, d;
cin >> a >> b >> c >> d;
if (a < b || d < b) {
cout << "No\n";
continue;
}
if (b <= c) {
cout << "Yes\n";
continue;
}
long g = gcd(b, d);
long cc = (a - c + g - 1) / g, bb = (a - b) / g;
cout << (cc - bb > 1 ? "No" : "Yes") << '\n';
}
cout << flush;
return 0;
}
|
#include <cstdio>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
if(b==0)return a;
return gcd(b,a%b);
}
int main(){
int T;
scanf("%d",&T);
while(T--){
ll a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b){puts("No");continue;}
if(d<b){puts("No");continue;}
if(a==c)a+=d;
ll t=(a-c-1)/gcd(b,d);
a=a-t*gcd(b,d);
a-=b;
if(a<0)puts("No");else puts("Yes");
}
return 0;
}
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long gcd(long long a,long long b)
{
if (b==0) return a;
return gcd(b,a%b);
}
int main()
{
int cas;
scanf("%d",&cas);
while (cas--)
{
long long a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if (a<b || d<b) { puts("No");continue; }
if (c>=b) { puts("Yes"); continue; }
long long x=gcd(b,d);a%=x;
if (a-c+(b-a-1)/x*x>=1) puts("No");
else puts("Yes");
}
return 0;
}
|
#include<iostream>
using namespace std;
long long gcd(long long a, long long b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
int main(){
long long t,a,b,c,d,i;
cin >> t;
for(i=0;i<t;i++){
cin >> a >> b >> c >> d;
if(a<b){
cout << "No" << endl;
continue;
}else if(d>=b && c>=b){
cout << "Yes" << endl;
continue;
}
if(b>d){
cout << "No" << endl;
continue;
}
long long x = a-b,y = a-c,z = gcd(b,d);
if(((y-1)/z)*z>x){
cout << "No" << endl;
}else{
cout << "Yes" << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long gcd(long long a,long long b) {
if(a%b==0)
return b;
return gcd(b,a%b);
}
int main() {
int i,j,k,ans=0;
cin>>n;
for(i=0; i<n; i++) {
long long a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(d<b || a<b) {
printf("No\n");
continue;
}
if(c+1>=b) {
printf("Yes\n");
continue;
}
long long g=gcd(b,d);
if((a-c-1ll)/g-(a-b)/g<=0)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
|
#include<iostream>
#include<algorithm>
using namespace std;
template<typename T>
T gcd(T a,T b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(int i=0;i<T;i++)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B || D<B || C<A%B || C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll a, b, c, d;
ll gcd(ll x, ll y) {
return y ? gcd(y, x % y) : x;
}
int main() {
scanf("%d", &t);
while (t--) {
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
if (b > a) puts("No");
else if (d < b) puts("No");
else if (c >= b) puts("Yes");
else {
d %= b; a %= b;
ll e = gcd(d, b), lim = (b - a - 1) / e;
a += lim * e;
if (a + e < b) a += e;
puts(a > c ? "No" : "Yes");
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a, int64_t b){
return b==0 ? a : gcd(b, a%b);
}
bool solve(){
int64_t A, B, C, D;
cin >> A >> B >> C >> D;
if(A < B || B > D) return false;
int64_t g = gcd(B, D);
int64_t r = A%g;
int64_t k = (C+g-r)/g;
int64_t lim = g*k+r;
return (lim >= B);
}
int main(){
int T;
cin >> T;
while(T--) cout << (solve() ? "Yes" : "No") << endl;
}
|
#include<iostream>
#include<algorithm>
using namespace std;
template<typename T>
T gcd(T a,T b)
{
if(a<b) swap(a,b);
T r = a % b;
while(r!=0)
{
a = b;
b = r;
r = a % b;
}
return b;
}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(int i=0;i<T;i++)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B || D<B || C<A%B || C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll A, B, C, D;
ll gcd(ll x, ll y) { return x? gcd(y % x, x): y; }
int main()
{
scanf("%d", &t);
while (t--) {
cin >> A >> B >> C >> D;
if (A < B) printf("No\n");
else if (D < B) printf("No\n");
else if (C >= B) printf("Yes\n");
else {
ll g = gcd(B, D);
ll k = (A - C + B - 1) / g;
if (A - C - k * g < -C) printf("No\n");
else printf("Yes\n");
}
}
return 0;
}
|
#include <iostream>
using namespace std;
long long gcd(long long x, long long y) {
if (y == 0) return x;
return gcd(y, x % y);
}
int main() {
int Q;
cin >> Q;
while (Q--) {
long long A, B, C, D;
cin >> A >> B >> C >> D; ++C;
long long g = gcd(B, D);
if (B > D || A - B < 0 || (A % g - C % g + g) % g + C - B < 0) {
cout << "No" << endl;
}
else {
cout << "Yes" << endl;
}
}
return 0;
}
|
#include<cstdio>
using namespace std;
long gcd(long a, long b){
if(b==0)
return a;
return gcd(b,a%b);
}
int main(){
int t;
long a,b,c,d,g;
scanf("%d",&t);
for(int i=0;i<t;i++){
scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
if(a<b||d<b)
printf("No\n");
else if(c>=b)
printf("Yes\n");
else{
g=gcd(b,d);
if(b-g+(a%g)>c)
printf("No\n");
else
printf("Yes\n");
}
}
}
|
#include <iostream>
using namespace std;
long long a,b,c,d,e,t;
long long gcd(long long b,long long d){
if(d==0) return b;
else return gcd(d,b%d);
}
int main(){
cin>>t;
while(t--){
cin>>a>>b>>c>>d;
e=gcd(b,d);
//cout<<a-(a-c-1)/e*e<<' ';
cout<<((a-(a-c-1)/e*e-b<0||a<b||d<b)?"No":"Yes")<<endl;
}
}
|
#include <bits/stdc++.h>
#define For(i, j, k) for (int i = j; i <= k; i++)
typedef long long LL;
LL A, B, C, D;
LL gcd(LL x, LL y) {
return !y ? x : gcd(y, x % y);
}
int main() {
scanf("%*d");
while (scanf("%lld%lld%lld%lld", &A, &B, &C, &D) == 4) {
if (A < B || B > D) { puts("No"); continue; }
if (C >= B) { puts("Yes"); continue; }
LL d = gcd(B, D);
A %= d;
LL x = C / d * d + A;
if (x <= C) x += d;
puts(x < B ? "No" : "Yes");
}
return 0;
}
|
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,c,d,g;
ll f(ll x,ll y){
if(y==0)return x;
return f(y,x%y);
}
int main(void){
cin>>n;
for(int i=0;i<n;i++){
cin>>a>>b>>c>>d;
g=f(b,d);
if(a<b||b>d){
cout<<"No"<<endl;
continue;
}
if(c>=b+1){
cout<<"Yes"<<endl;
continue;
}
if(a%g+b-g>c){
cout<<"No"<<endl;
}
else cout<<"Yes"<<endl;
}
}
|
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
int T; scanf("%d", &T);
while(T --) {
ll a, b, c, d; scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
ll g = gcd(b, d);
if(b > a || b > d) puts("No");
else if(c + 1 >= b) puts("Yes");
else puts((a - c - 1) / g > (a - b) / g ? "No" : "Yes");
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll a,b,c,d;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
cin>>t;
while(t--){
cin>>a>>b>>c>>d;
if(a<b){
printf("No\n");continue;
}
if(b>d){
printf("No\n");continue;
}
if(c>=(b-1)){
printf("Yes\n");continue;
}
if(((a%b+((b-1-a%b)/gcd(b,d))*gcd(b,d))>c)) printf("No\n");
else printf("Yes\n");
}
return 0;
}
|
#include<iostream>
using namespace std;
template<typename T>
T gcd(T x,T y){return y?gcd(y,x%y):x;}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(;0<T;T--)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
long long gcd(long long a, long long b) {
return b == 0 ? a : gcd(b, a % b);
}
int main()
{
int T;
long long A, B, C, D;
cin >> T;
while (T--) {
cin >> A >> B >> C >> D;
if (A < B || D < B) cout << "No\n";
else {
long long g = gcd(B, D);
if (B - (g - A % g) > C) cout << "No\n";
else cout << "Yes\n";
}
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int t;
long long a, b, c, d;
long long gcd(long long a, long long b){
if(a < b) swap(a, b);
while(b){
a %= b;
swap(a, b);
}
return a;
}
int main(){
scanf("%d", &t);
for (int i = 0; i < t; ++i){
bool ans = true;
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
if(b > d || b > a) ans = false;
else if(b > c + 1){
long long e = gcd(d, b);
if(a % e - e + b > c) ans = false;
}
printf("%s\n", ans ? "Yes" : "No");
}
}
|
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
if(y == 0)return x;
return gcd(y,x%y);
}
int main(){
int T;
scanf("%d",&T);
for(;T>0;T--){
ll A,B,C,D;
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
if(B > D || A < B){
puts("No");
continue;
}
ll g = gcd(B,D);
if(A%g > C%g)C -= g;
if(C < 0)C = -1;
else C /= g;
B /= g;
if(C+1 >= B)puts("Yes");
else puts("No");
}
}
|
#include <iostream>
#include <vector>
#define llint long long
using namespace std;
llint T;
llint a, b, c, d;
llint gcd(llint a, llint b){
if(b == 0) return a;
return gcd(b, a%b);
}
int main(void)
{
cin >> T;
for(int t = 0; t < T; t++){
cin >> a >> b >> c >> d;
if(d < b || a < b){
cout << "No" << endl;
continue;
}
if(c >= b){
cout << "Yes" << endl;
continue;
}
llint g = gcd(b, d);
a = a%b%g;
a = (a+b-g)%b;
if(a > c) cout << "No" << endl;
else cout << "Yes" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d;
ll gcd(ll x,ll y){
return y==0?x:gcd(y,x%y);
}
int main(){
int t,flag; cin>>t;
while(t--){
flag=0;
cin>>a>>b>>c>>d;
if (d<b) flag=1;
if (a<b) flag=1;
a-=a/b*b;
if (a>c) flag=1;
d-=(d/b-1)*b;
if (gcd(d,b)<b-c) flag=1;
if (flag) puts("No");
else puts("Yes");
}
return 0;
}
|
#include<cstdio>
#define LL long long
int t;
LL a,b,c,d;
LL gcd(LL a,LL b)
{
if(!b) return a;
return gcd(b,a%b);
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b) printf("No\n");
else if(d<b) printf("No\n");
else if(c>=b) printf("Yes\n");
else if(b-gcd(b,d)+a%gcd(b,d)>c) printf("No\n");
else printf("Yes\n");
//printf(" %lld %lld %lld\n",b,gcd(b,d),(c-a%b+b)%b);
}
}
|
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll a,b,c,d;
ll gcd(ll x,ll y){
if(!y) return x;
return gcd(y,x%y);
}
int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b||d<b){printf("No\n"); continue;}
if(c>=b){printf("Yes\n"); continue;}
ll l=a-b,r=a-c-1;
ll x=gcd(b,d);
if(r/x-l/x>0) printf("No\n");
else printf("Yes\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
return !b ? a : gcd(b, a % b);
}
bool check(long long l, long long r, long long a, long long b) {
b %= a;
l += a - b, r += a - b;
return r / a > (l - 1) / a;
}
int main() {
int T;
cin >> T;
while (T--) {
long long A, B, C, D;
cin >> A >> B >> C >> D;
puts(A < B || B > D || check(C + 1, B - 1, gcd(B, D), A) ? "No" : "Yes");
}
return 0;
}
|
#include <iostream>
#include <algorithm>
using namespace std;
long long gcd(long long p, long long q) {
if (q == 0)
return p;
else
gcd(q, p % q);
}
int main()
{
int t;
long long a, b, c, d;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> a >> b >> c >> d;
long long g = gcd(b, d);
if (a >= b && b <= d && g >= b - c && a % g <= c)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
ll a, b, c, d;
cin >> a >> b >> c >> d;
bool r = false;
if (a - b >= 0 && d >= b) {
ll k = gcd(b, d);
ll x = a <= c ? a + ((c - a) / k + 1) * k : c + (a - c - 1) % k + 1;
r = x - b >= 0;
}
cout << (r ? "Yes" : "No") << endl;
}
}
|
#include<cstdio>
#include<algorithm>
using namespace std;
int n, res;
long long gcd(long long a, long long b) {
return b?gcd(b, a%b) :a;
}
int main() {
long long a, b, c, d;
int TC;
scanf("%d", &TC);
while (TC--) {
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
long long g = gcd(b, d);
long long t = a % g;
if (t <= c) t += (c - t) / g*g;
while (t <= c)t += g;
if (t >= b && a>=b && b<=d)puts("Yes");
else puts("No");
}
}
|
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
if (b == 0) return a;
else return gcd(b, a % b);
}
int main() {
int T; cin >> T;
for (int i = 0; i < T; i++) {
ll A, B, C, D; cin >> A >> B >> C >> D;
if (A < B) {
cout << "No" << endl;
continue;
}
else if (D < B) {
cout << "No" << endl;
continue;
}
else if (C > B) {
cout << "Yes" << endl;
continue;
}
ll G = gcd(B, D);
if (A % G + B - G > C) cout << "No" << endl;
else cout << "Yes" << endl;
}
return 0;
}
|
#include <cstdio>
typedef long long ll;
ll Gcd(const ll a,const ll b){return b?Gcd(b,a%b):a;}
int T;
ll A,B,C,D;
bool Limited()
{
if(A<B)return true;
if(B>D)return true;
if(B-C<2)return false;
ll Gs=Gcd(B,D),L=A-B+1,R=A-C-1;
ll Boundary=(L+Gs-1)/Gs*Gs;
return Boundary<=R;
}
int main()
{
for(scanf("%d",&T);T--;)
{
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
puts(Limited()?"No":"Yes");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gc(long long a,long long b){
if(a<=b) swap(a,b);
if(a%b==0) return b;
else return gc(b,a%b);
}
int main() {
int T;
cin>>T;
int i,j;
long long a,b,c,d;
for(i=0;i<T;i++){
cin>>a>>b>>c>>d;
if(b>d) cout<<"No"<<endl;
else if(b>a) cout<<"No"<<endl;
else{
long long e=gc(b,d);
long long f=(a-c)/e;
f-=1;
long long k=a-e*f;
if(k-e>c) k-=e;
if(k<b) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y)
{
return y?gcd(y,x%y):x;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b||d<b)printf("No\n");
else if(c>=b)printf("Yes\n");
else
{
long long l=a-b,r=a-c-1;
long long t=gcd(b,d);
if(l/t==r/t)printf("Yes\n");
else printf("No\n");
}
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
if(abs(a-b)==1) return (ll)1;
if(a==0) return b;
return gcd(b%a,a);
}
int main()
{
int T;cin>>T;
ll a,b,c,d;
while(T--)
{
cin>>a>>b>>c>>d;
if(b>d || b>a)
{
cout<<"No"<<endl;
continue;
}
ll x=(a-c)/b;
if(x*b!=a-c) x++;
a-=x*b;
if(a<0)
{
cout<<"No"<<endl;
continue;
}
if(gcd(b,d)+c>=b)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
|
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
int _test;
LL A,B,C,D;
LL gcd(LL a,LL b){ return b?gcd(b,a%b):a; }
int main(){
scanf("%d",&_test);
while(_test--){
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
if(A>C) A=(A-C-1)%B+C+1;
if(A<B||D<B) puts("No"); else{
A%=B; D%=B; LL d=gcd(B,D);
if((C-A)/d<(B-A-1)/d) puts("No"); else puts("Yes");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y){
return y == 0 ? x : gcd(y, x % y);
}
int main(){
int T;
scanf("%d",&T);
long long a, b, c, d, gcdbd;
while (T--){
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
if (a < b || d < b) printf("No\n");
else if (c >= b) printf("Yes\n");
else{
gcdbd = gcd(b, d);
if (b - gcdbd + a % gcdbd > c) printf("No\n");
else printf("Yes\n");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
ll a, b, c, d;
cin >> a >> b >> c >> d;
bool r = false;
if (a - b >= 0 && d >= b) {
a -= b;
ll k = gcd(b, d);
ll x = a <= c ? a + ((c - a) / k + 1) * k : c + (a - c - 1) % k + 1;
r = x - b >= 0;
}
cout << (r ? "Yes" : "No") << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
if(x < y)
return gcd(y, x);
if(y == 0)
return x;
return gcd(y, x%y);
}
int main(){
long long a, b, c, d;
int t;
cin >> t;
while(t--){
cin >> a >> b >> c >> d;
ll g = gcd(d, b);
ll r = a - (a/g)*g - g;
if(a < b || d < b || c < b-1 && c-b < r)
cout << "No\n";
else cout << "Yes\n";
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y){
return y==0?x:gcd(y,x%y);
}
int main(){
//freopen("aa.in","r",stdin);
int _;scanf("%d",&_);
for(;_--;){
long long A,B,C,D;
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
if(A<B||D<B){puts("No");continue;}
if(C>=B-1){puts("Yes");continue;}
long long G=gcd(B,D);
A%=G;
if(-G+A>=C-B+1)puts("No");
//if(A==0&&-G>=C-B+1||A&&A>=C-B+1)puts("No");
else puts("Yes");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
llint gcd(llint a, llint b)
{
while (b)
{
tie(a, b) = make_pair(b, a % b);
}
return a;
}
bool solve()
{
llint a, b, c, d, x;
cin>>a>>b>>c>>d;
if (a < b)
return false;
a %= b;
if (a > c)
return false;
x = gcd(b, d);
if (a % x + d < b)
return false;
return b - x + a % x <= c;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while (t--)
{
cout<<(solve() ? "Yes\n" : "No\n");
}
}
|
#include <iostream>
using namespace std;
using ll = long long;
const string YES = "Yes", NO = "No";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll A, B, C, D;
string solve() {
if (A < B || B > D) return NO;
if (B <= C) return YES;
ll v = gcd(D, B);
return B - v + (A % v) <= C ? YES : NO;
}
int main(void) {
int T; cin >> T;
for (int i = 0; i < T; ++i) {
cin >> A >> B >> C >> D;
cout << solve() << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#define For(i, j, k) for (int i = j; i <= k; i++)
typedef long long LL;
LL A, B, C, D;
LL gcd(LL x, LL y) {
return !y ? x : gcd(y, x % y);
}
int main() {
scanf("%*d");
while (scanf("%lld%lld%lld%lld", &A, &B, &C, &D) == 4) {
if (A < B || B > D) { puts("No"); continue; }
if (C >= B) { puts("Yes"); continue; }
LL d = gcd(B, D);
A %= d;
LL x =( (C / d) * d) + A;
if (x <= C) x += d;
puts(x < B ? "No" : "Yes");
}
return 0;
}
|
#include<stdio.h>
template<typename T>
T gcd(T x,T y){return y?gcd(y,x%y):x;}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(;0<T;T--)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
}
|
#include <stdio.h>
typedef long long ll;
ll gcd(ll a,ll b) {
return b?gcd(b,a%b):a;
}
inline bool solve(ll k,ll x,ll m,ll n) {
if(x<k||k>n) return false;
if(m>=k) return true;
ll a=m-k,b=gcd(n,k),c=x%b;
ll d=(a/b-1)*b+c;
while(d<a) d+=b;
return d>=0;
}
int main() {
int T; scanf("%d",&T);
while(T--) {
ll a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
puts(solve(b,a,c+1,d)?"Yes":"No");
}
return 0;
}
|
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a%b);
}
long long N, A, B, C, D;
int main() {
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> A >> B >> C >> D;
if (A < B) cout << "No" << endl;
else if (B > D) cout << "No" << endl;
else if (B <= C) cout << "Yes" << endl;
else {
long long S = gcd(B, D);
long long T = ((B / S) - 1) * S + A % S;
if (T > C) cout << "No" << endl;
else cout << "Yes" << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, c, d;
ll gcd(ll a, ll b){
return a == 0 ? b : gcd(b % a, a);
}
bool solve(ll a, ll b, ll c, ll d){
if(d < b || a < b) return false;
if(c >= b) return true;
ll g = gcd(b, d);
ll rem = g - a % g;
return (b - c) <= rem;
}
int main(){
int T;
cin >> T;
while(T--){
cin >> a >> b >> c >> d;
if(solve(a, b, c, d)) printf("Yes\n");
else printf("No\n");
}
}
|
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long gcd(long long x,long long y)
{
if (y==0) return x;
else return gcd(y,x%y);
}
int main()
{
int n;
scanf("%d",&n);
while (n--)
{
long long a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if ((a<b) || (d<b)) {printf("No\n");continue;}
if (b<=c) {printf("Yes\n");continue;}
long long g=gcd(b,d);
if ((a-c-1)/g-(a-b)/g>0) printf("No\n");
else printf("Yes\n");
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int main(){
ll T;
cin >> T;
for(ll query = 0; query < T; query++){
ll A, B, C, D;
cin >> A >> B >> C >> D;
if(A < B || B > D){
cout << "No";
}else if(C >= B){
cout << "Yes";
}else{
ll g = gcd(B, D);
if(B - g + A % g <= C) cout << "Yes";
else cout << "No";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int T;
ll A, B, C, D;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main() {
scanf("%d", &T);
for (int i = 0; i < T; ++i) {
scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
if (A < B || D < B) {
printf("No\n");
continue;
}
if (C >= B) {
printf("Yes\n");
continue;
}
ll d = gcd(D, B);
if (B - d + A % d > C) printf("No\n");
else printf("Yes\n");
}
}
|
#include <iostream>
#define ll long long
using namespace std;
ll gcd(ll a, ll b){
if(a%b>0) return gcd(b, a%b);
return b;
}
bool judge(ll a, ll b, ll c, ll d){
if(min(a, d)<b) return false;
ll n=gcd(b, d);
ll r=c/n;
if(a%n>c%n) --r;
return r+1 > b/n-1;
}
int main() {
int T;
cin >> T;
ll A, B, C, D;
for(int t=0; t<T; ++t){
cin >> A >> B >> C >> D;
if(judge(A, B, C, D)) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}
|
#include<iostream>
#include<algorithm>
using namespace std;
long gcd(long a, long b){
if(b==0) return a;
return gcd(b, a%b);
}
int main(){
int t;
long a, b, c, d;
cin >> t;
for(int i=0;i<t;i++){
cin >> a >> b >> c >> d;
if(a < b || d < b){
cout << "No" << endl;
}else if(b <= min(c, d)){
cout << "Yes" << endl;
}else{
long g = gcd(b, d);
long max_ = b - g + a % g;
if(max_ <= c){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}
}
}
|
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a,b,c,d;
inline LL gcd(LL x,LL y)
{
return !y?x:gcd(y,x%y);
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b||d<b||a%b>c)
{
printf("No\n");
continue;
}
if(b<c||d%b==0)
{
printf("Yes\n");
continue;
}
LL x=a%b,y=gcd(d,b);
if((((c+1-x)%y+b-c-2)>=y||(c+1-x)%y==0)&&b-c>1)
printf("No\n");
else
printf("Yes\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b) {
if (a < b) swap(a, b);
return b ? gcd(b, a % b) : a;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; ++i){
ll a, b, c, d;
cin >> a >> b >> c >> d;
if (b > d || a < b) cout << "No" << endl;
else {
ll g = gcd(b, d);
ll p = c + g - (c - a % g + g) % g;
cout << (p - b >= 0 ? "Yes" : "No") << endl;
}
}
return 0;
}
|
// B.
#include <sstream>
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
int main(int argc, char *argv[])
{
int t;
cin >> t;
for (int tt = 0; tt < t; ++tt) {
LL a, b, c, d;
cin >> a >> b >> c >> d;
bool ans = a >= b && b <= d;
if (ans && b > c) {
LL r = a % b;
LL p = d % b;
if (p) {
LL g = gcd(p, b);
r = b + r - (r / g + 1) * g;
}
ans = r <= c;
}
cout << (ans ? "Yes" : "No") << endl;
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,a,b,c,d;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
int main(){
cin>>t;
while(t--){
cin>>a>>b>>c>>d;
{
ll g=gcd(b,d);
bool flag=a%g>c%g;
a/=g;
b/=g;
c/=g;
d/=g;
if(flag)
--c;
}
if(b>d||a<b||c+1<b)
puts("No");
else
puts("Yes");
}
return 0;
}
|
#include <stdio.h>
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
int t;
ll a,b,c,d,k;
scanf("%d",&t);
for(;t--;){
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(b>a||b>d){puts("No");continue;}
if(a<c){
if(b==d){puts("Yes");continue;}
k=(c-a-1)/(d-b)+1;
a+=k*(d-b);
}
k=(a-c+b-1)/b;
if(a<k*b){puts("No");continue;}
a-=k*b;
d=gcd(d,b);
k=(c-a)/d+1;
puts(a+d*k<b?"No":"Yes");
}
return 0;
}
|
#include<cstdio>
#include<algorithm>
using namespace std;
long long gcd(long long a, long long b) {
while(b){
a%=b;
swap(a,b);
}
return a;
}
long long t,a,b,c,d;
int main(){
scanf("%lld",&t);
for (int i=1;i<=t;i++) {
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
int x=0;
long long z=(a-c)%gcd(b,d);//Icannotunderstand
if(z==0)z=gcd(b, d);
if(b-c<=z)x=1;//Icanunderstand
if(a<b||d<b)x=0;//Icanunderstand
if(x==0)printf("No\n");
else printf("Yes\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ll gcd(ll a, ll b){
if(a<b) swap(a, b);
if(b==0) return a;
return gcd(b, a%b);
}
int main(){
int t;
cin >> t;
for(int i=0; i<t; i++){
ll a, b, c, d;
cin >> a >> b >> c >> d;
if(a<b || d<b) cout << "No" << endl;
else if(b-1<=c) cout << "Yes" << endl;
else{
ll g=gcd(b, d);
if(b-g+a%g<=c) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
return 0;
}
|
#include<stdio.h>
template<typename T>
T gcd(T x,T y){return y?gcd(y,x%y):x;}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(;0<T;T--)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
return 0;
}
|
#include <cstdio>
#include <algorithm>
#include <stdint.h>
int64_t gcd(int64_t a,int64_t b){
return b?gcd(b,a%b):a;
}
bool solve(){
int64_t A,B,C,D;
scanf("%ld %ld %ld %ld",&A,&B,&C,&D);
if(A<B||D<B){
return false;
}
int64_t g=gcd(B,D);
A%=g;
A+=std::max<int64_t>(0,C-A+g)/g*g;
return A>=B;
}
int main(){
int64_t T;
scanf("%ld",&T);
while(T--){
if(solve()){
printf("Yes\n");
}else{
printf("No\n");
}
}
return 0;
}
|
#include <iostream>
using namespace std;
long long gcd(long long x, long long y) {
if (y == 0) return x;
return gcd(y, x % y);
}
int main() {
int Q;
cin >> Q;
for (int i = 0; i < Q; ++i) {
long long A, B, C, D;
cin >> A >> B >> C >> D;
bool ans = true;
if (A < B || B > D) ans = false;
else {
long long g = gcd(B, D);
long long tar = -1;
if (B % g > A % g) tar = B / g * g + A % g;
else tar = (B / g - 1) * g + A % g;
if (tar > C) ans = false;
}
cout << (ans ? "Yes" : "No") << endl;
}
return 0;
}
|
#include<iostream>
using namespace std;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
int t;
long A,B,C,D;
int main()
{
cin>>t;
for(;t--;)
{
cin>>A>>B>>C>>D;
if(A<B)cout<<"No"<<endl;
else
{
if(B>D)cout<<"No"<<endl;
else
{
if(B-1<=C)cout<<"Yes"<<endl;
else
{
long b=B-A%B,c=C-A%B;
long dis=gcd(B,D);
if(b>(c+dis)/dis*dis)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
}
}
}
|
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
ll a, b, c, d, g;
ll gcd(ll x, ll y){
return y == 0 ? x : gcd(y, x % y);
}
int main(){
cin >> n;
while (n--){
cin >> a >> b >> c >> d;
if (a < b || d < b) cout << "No\n";
else if (c >= b) cout << "Yes\n";
else {
g = gcd(b, d);
if (b - g + a % g > c) cout << "No\n";
else cout << "Yes\n";
}
}
return 0;
}
|
#include<stdio.h>
template<class T>
T gcd(T x,T y){return y?gcd(y,x%y):x;}
int main()
{
int T; scanf("%d",&T);
unsigned long int A,B,C,D;
for(;0<T;T--)
{
scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
if(A<B||D<B||C<A%B||C<B-gcd(B,D)) puts("No");
else puts("Yes");
}
}
|
#include<iostream>
using namespace std;
long long gcd(long long a, long long b) {
long long c;
if (a < b)a += b, b = a - b, a -= b;
while (b != 0) c = a % b, a = b, b = c;
return a;
}
int main() {
long long t, a, b, c, d;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> a >> b >> c >> d;
int x = 0;
long long z = (a - c) % gcd(b, d);
z += gcd(b, d);
z = z % gcd(b, d);
if (z == 0) z = gcd(b, d);
if (b - c <= z) x = 1;
if (a < b || d < b) x = 0;
if (x == 0) cout << "No" << endl;
else cout << "Yes" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y){
if (x<y) return gcd(y,x);
else if(x%y == 0) return y;
else return gcd(y,x%y);
}
int main(){
int T;
cin >> T;
for (int i=0; i<T; i++){
long long A, B, C, D;
cin >> A >> B >> C >>D;
if ((D < B) || (A < B)){
cout <<"No" << endl;
} else if (C >= B){
cout << "Yes" << endl;
} else if ((C >= B-gcd(B,D)) && (A%B <= C)){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
|
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
using namespace std;
typedef long long LL;
LL A, B, C, D, g, mx;
LL gcd(LL a, LL b) {return b? gcd(b, a % b): a;}
int main() {
int T;
scanf("%d", &T);
while(T--) {
scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
if(A < B) {puts("No"); continue;}
if(D < B) {puts("No"); continue;}
if(C >= B) {puts("Yes"); continue;}
g = gcd(B, D);
mx = (B - A%B - 1) / g * g + A%B;
if(mx > C) puts("No"); else puts("Yes");
}
return 0;
}
|
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
if (a < b) swap(a, b);
while (b > 0) { long long t = a; a = b; b = t % b; }
return a;
}
int main() {
int t; cin >> t;
while (t--) {
long long A, B, C, D; cin >> A >> B >> C >> D;
if (A < B || B > D) cout << "No\n";
else if (B-1 <= C) cout << "Yes\n";
else {
long long g = gcd(B, D);
cout << (C + 1 > A % B + (B - A % B - 1) / g * g ? "Yes\n" : "No\n");
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
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(a < b) return false;
if(b > d) return false;
if(b <= c) return true;
ll g = gcd(b,d);
return c >= b - g + a%g;
}
int main(void){
ll T;
cin>>T;
rep(_,T){
ll a,b,c,d;
cin>>a>>b>>c>>d;
cout<<((solve(a,b,c,d)) ? "Yes" : "No")<<endl;
}
return 0;
}
|
#include "bits/stdc++.h"
using namespace std;
long long GCD(long long X, long long Y) {
if (Y == 0) return X;
return GCD(Y, X % Y);
}
int main() {
long long T;
cin >> T;
for (int i = 0; i < T; i++) {
long long A, B, C, D;
cin >> A >> B >> C >> D;
if (A < B) cout << "No" << endl;
else if (D < B) cout << "No" << endl;
else if (B <= C + 1) cout << "Yes" << endl;
else {
if (C - A % GCD(B, D) >= B - GCD(B, D)) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
}
|
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
long long int gcd(long long int x, long long int y){
long long int r;
if(x < y) swap (x, y);
while(y > 0){
r = x % y;
x = y;
y = r;
}
return x;
}
int main() {
int T;
long long int A, B, C, D;
cin >> T;
for (int i = 0; i < T; i++){
cin >> A >> B >> C >> D;
long long int E = A - (A - C + B - 1)/ B * B;
if(A < B || E < 0) cout << "No" << endl;
else if(C < B - gcd(B, D) || B > D)
cout << "No" << endl;
else cout << "Yes" << endl;
}
}
|
#include <iostream>
using namespace std;
long gcd(long a, long b) {
if (b == 0) return a;
return gcd(b, a%b);
}
int main() {
long a, b, c, d, e, f;
cin >> a;
for (int i = 0; i < a; ++i) {
cin >> b >> c >> d >> e;
if (b < c || e < c) {
cout << "No" << endl;
}
else if (d >= c) {
cout << "Yes" << endl;
}
else {
f = gcd(c, e);
if (c - f + (b%f) > d) cout << "No" << endl;
else cout << "Yes" << endl;
}
}
}
|
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd(ll n,ll m){
if(m==0) return n;
else return gcd(m,n%m);
}
int main(){
ll n,a,b,c,d,ok;
cin >> n;
for(ll i=0;i<n;i++){
cin >> a >> b >> c >> d;
ll x=gcd(b,d);
ll ok=b-x+a%x;
if(a<b||d<b) cout << "No" << endl;
else if(c>=b) cout << "Yes" << endl;
else if(c>=ok) cout << "Yes" << endl;
else cout << "No" << endl;
}
}
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll t;
cin>>t;
for(ll i=0;i<t;i++){
ll a,b,c,d;
cin>>a>>b>>c>>d;
if(a<b) {
cout<<"No"<<endl;
continue;
}
else if(b>d){
cout<<"No"<<endl;
continue;
}
else if(b<=c){
cout<<"Yes"<<endl;
continue;
}
ll fb=b;
if(b<d) swap(b,d);
while(b%d!=0){
ll md=b%d;
b=d;
d=md;
}
ll max_v=fb-d+(a%d);
if(max_v>c) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
|
#include<bits/stdc++.h>
using namespace std;
long g(long m,long n){
return (n==0?m:g(n,m%n));
}
int main(){
long n, a, b, c, d;
cin >> n;
for(int i=0;i<n;i++){
cin >> a >> b >> c >> d;
cout << ((c>=b-g(b,d)+a%g(b,d)||c>=b)&&!(b>a||b>d)?"Yes":"No") << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
long long gcd(long long x, long long y){
if (y == 0)
return x;
return gcd(y, x % y);
}
int main(){
int T;
cin >> T;
while (T --){
long long a, b, c, d;
cin >> a >> b >> c >> d;
if (a < b)
cout << "No" << endl;
else if (b > d)
cout << "No" << endl;
else if (c >= b - 1)
cout << "Yes" << endl;
else{
// a %= b, c %= b, d %= b;
long long g = gcd(d, b);
if ((a - b) / g < (a - c - 1) / g)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
}
}
|
#include<cstdio>
#include<algorithm>
#include<iostream>
typedef long long ll;
using namespace std;
ll T,a,b,c,d,g;
ll gcd(ll a,ll b){ return b ? gcd(b,a%b) : a; }
int main(){
for (cin>>T; T--; ){
cin>>a>>b>>c>>d; g=gcd(d,b);
if (a<b || d<b || (a-(a-c-1)/g*g)-b<0) cout<<"No\n"; else cout<<"Yes\n";
}
return 0;
}
|
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
if(a%b==0) return b;
return gcd(b,a%b);
}
int main(){
int t; cin>>t;
while(t--){
ll a,b,c,d; cin>>a>>b>>c>>d;
if(a<b){
cout<<"No\n"; continue;
}
if(d<b){
cout<<"No\n"; continue;
}
ll t1=gcd(b,d);
ll t2=(a-b)/t1; t2++;
if(t2*t1 < (a-c)) cout<<"No\n";
else cout<<"Yes\n";
}
return 0;
}
|
#include <iostream>
using namespace std;
long long gcd(long long a, long long b){
if(a%b == 0) return b;
return gcd(b, a%b);
}
bool solve(){
long long A, B, C, D; cin >> A >> B >> C >> D;
if(A < B) return false;
if(D < B) return false;
if(C >= B) return true;
long long a = A%B;
long long d = gcd(B, D);
long long m = B - d + A%B%d;
return m <= C;
}
int main(){
int T;
while(cin >> T){
for(int i=0;i<T;i++){
cout << (solve() ? "Yes" : "No") << endl;
}
}
}
|
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long gcd(long long x,long long y)
{
if(y==0)
return x;
return gcd(y,x%y);
}
int main()
{
int T;
long long a,b,c,d;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a<b||d<b)
{
printf("No\n");
continue;
}
a%=b;
d=gcd(d,b);
if(d!=b)
{
a%=d;
a=a+b-d;
}
if(a>c)
printf("No\n");
else
printf("Yes\n");
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.