CF1929C.Sasha and the Casino

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sasha decided to give his girlfriend the best handbag, but unfortunately for Sasha, it is very expensive. Therefore, Sasha wants to earn it. After looking at earning tips on the internet, he decided to go to the casino.

Sasha knows that the casino operates under the following rules. If Sasha places a bet of yy coins (where yy is a positive integer), then in case of winning, he will receive yky \cdot k coins (i.e., his number of coins will increase by y(k1)y \cdot (k - 1) ). And in case of losing, he will lose the entire bet amount (i.e., his number of coins will decrease by yy ).

Note that the bet amount must always be a positive ( >0> 0 ) integer and cannot exceed Sasha's current number of coins.

Sasha also knows that there is a promotion at the casino: he cannot lose more than xx times in a row.

Initially, Sasha has aa coins. He wonders whether he can place bets such that he is guaranteed to win any number of coins. In other words, is it true that for any integer nn , Sasha can make bets so that for any outcome that does not contradict the rules described above, at some moment of time he will have at least nn coins.

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. The description of the test cases follows.

The single line of each test case contains three integers k,xk, x and aa ( 2k302 \leq k \leq 30 , 1x1001 \leq x \leq 100 , 1a1091 \leq a \leq 10^9 ) — the number of times the bet is increased in case of a win, the maximum number of consecutive losses, and the initial number of coins Sasha has.

输出格式

For each test case, output "YES" (without quotes) if Sasha can achieve it and "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, the strings "yEs", "yes" and "Yes" will be recognized as a positive answer).

输入输出样例

  • 输入#1

    9
    2 1 7
    2 1 1
    2 3 15
    3 3 6
    4 4 5
    5 4 7
    4 88 1000000000
    25 69 231
    13 97 18806

    输出#1

    YES
    NO
    YES
    NO
    NO
    YES
    NO
    NO
    NO

说明/提示

In the first test case, Sasha can proceed as follows:

  • If Sasha places a bet for the first time or if he won the previous bet, then he places 11 coin.
  • If Sasha lost the previous bet, then he places 22 coins.

Note that Sasha cannot lose more than once in a row.

It can be proven that with this strategy, Sasha can obtain as many coins as he wants.

In the second test case, Sasha can only place 11 coin for the first time. But in case of a loss, he will not be able to place any more bets, so he will not be able to guarantee having as many coins as he wants.

首页