CF1929C.Sasha and the Casino
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
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 y coins (where y is a positive integer), then in case of winning, he will receive y⋅k coins (i.e., his number of coins will increase by y⋅(k−1)). And in case of losing, he will lose the entire bet amount (i.e., his number of coins will decrease by y).
Note that the bet amount must always be a positive ($ \gt 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 x times in a row.
Initially, Sasha has a 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 n, 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 n coins.
萨沙决定送给女友一款最好的手袋,但不幸的是,这款手袋价格非常昂贵。因此,萨沙打算靠自己赚取这笔钱。在上网查阅了各种赚钱小贴士后,他决定去赌场碰碰运气。
萨沙了解到,该赌场的运营规则如下:若萨沙下注 y 枚硬币(其中 y 为正整数),则若获胜,他将获得 y⋅k 枚硬币(即其硬币总数将增加 y⋅(k−1) 枚);若失败,则他将输掉全部赌注(即其硬币总数将减少 y 枚)。
注意:每次下注金额必须为正整数(即 >0),且不得超过萨沙当前所拥有的硬币数量。
萨沙还得知,赌场当前正开展一项促销活动:他连续失败的次数不能超过 x 次。
初始时,萨沙拥有 a 枚硬币。他想知道:是否存在一种下注策略,使得他必然能够赢得任意多的硬币?换言之,是否对任意整数 n,都存在一种下注方式,使得在所有不违反上述规则的可能结果序列下,萨沙在某一时刻所拥有的硬币数至少达到 n?
输入格式
Each test consists of multiple test cases. The first line contains a single integer t (1≤t≤1000) — the number of test cases. The description of the test cases follows.
The single line of each test case contains three integers k,x and a (2≤k≤30, 1≤x≤100, 1≤a≤109) — 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.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤1000),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例占一行,包含三个整数 k,x 和 a(2≤k≤30,1≤x≤100,1≤a≤109),分别表示获胜时赌注增加的倍数、最多允许的连续失败次数,以及萨沙初始拥有的硬币数量。
输出格式
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).
对于每个测试用例,如果萨沙能够实现目标,则输出 “YES”(不带引号),否则输出 “NO”(不带引号)。
“YES” 和 “NO” 可以以任意大小写形式输出(例如,字符串 “yEs”、“yes” 和 “Yes” 均会被识别为肯定回答)。
输入输出样例
输入#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 1 coin.
- If Sasha lost the previous bet, then he places 2 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 1 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.
在第一个测试用例中,萨沙可以按如下方式操作:
- 如果萨沙是第一次下注,或者他上一次下注赢了,则他下注 1 枚硬币;
- 如果萨沙上一次下注输了,则他下注 2 枚硬币。
注意:萨沙不可能连续输两次以上。
可以证明,采用该策略,萨沙能够获得任意多的硬币。
在第二个测试用例中,萨沙第一次只能下注 1 枚硬币。但如果这次下注输了,他将无法再进行任何下注,因此他无法保证获得任意多的硬币。
输入解题思路,AI测评打分。不知道怎么写?