forked from deepanshumishra/JavaAndCPP_programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathALTER.java
More file actions
48 lines (42 loc) · 904 Bytes
/
Copy pathALTER.java
File metadata and controls
48 lines (42 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package codechef_lib;
import java.util.Scanner;
public class ALTER {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i=1;i<=t;i++) {
int a = sc.nextInt();int a_worked=0;
int b = sc.nextInt();int b_worked=0;
int p = sc.nextInt();
int q = sc.nextInt();
int day = 1;
boolean dokill=false;
while(!dokill) {
if(b_worked<q) {
if(day%2!=0) {
b_worked+=b;day++;
}else {
break;
}
}
if(a_worked<p ) {
if(day%2==0) {
a_worked += a;day++;
}else {
break;
}
}
if(a_worked>=p && b_worked>=q) {
dokill = true;
break;
}
}
if(a_worked==p && b_worked==q ) {
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
}