Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int q, money, coin, price, need, gcd, req;
- int FindGCD(int a, int b){
- int x = max(a, b);
- int y = min(a, b);
- int r = x % y;
- while(r != 0){
- x = y;
- y = r;
- r = x % y;
- }
- return y;
- }
- int main(){
- scanf("%d", &q);
- for(int i = 0; i < q; ++i){
- scanf("%d %d %d %d", &money, &need, &coin, &price);
- gcd = FindGCD(need, coin);
- req = need / gcd * price;
- if(money >= req){
- cout << "Yes\n";
- } else {
- cout << "No\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement