codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1256A.md (1396B)


      1 Source: https://codeforces.com/problemset/problem/1256/A
      2 
      3 A. Payment Without Change
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You have $a$ coins of value $n$ and $b$ coins of value $1$. You always pay in exact change, so you want to know if there exist such $x$ and $y$ that if you take $x$ ($0 \le x \le a$) coins of value $n$ and $y$ ($0 \le y \le b$) coins of value $1$, then the total value of taken coins will be $S$.
     22 
     23 You have to answer $q$ independent test cases.
     24 
     25 Input
     26 
     27 The first line of the input contains one integer $q$ ($1 \le q \le 10^4$) — the number of test cases. Then $q$ test cases follow.
     28 
     29 The only line of the test case contains four integers $a$, $b$, $n$ and $S$ ($1 \le a, b, n, S \le 10^9$) — the number of coins of value $n$, the number of coins of value $1$, the value $n$ and the required total value.
     30 
     31 Output
     32 
     33 For the $i$-th test case print the answer on it — YES (without quotes) if there exist such $x$ and $y$ that if you take $x$ coins of value $n$ and $y$ coins of value $1$, then the total value of taken coins will be $S$, and NO otherwise.
     34 
     35 You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
     36 
     37 Example
     38 
     39 Input
     40 
     41 ```
     42 4
     43 1 2 3 4
     44 1 2 3 6
     45 5 2 6 27
     46 3 3 5 18
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 YES
     53 NO
     54 NO
     55 YES
     56 ```