A11329 | Sasha and the Casino
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 \cdot k$ coins (i.e., his number of coins will increase by $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 $y$ ).
Note that the bet amount must always be a positive ( $> 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.
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 \cdot k$ coins (i.e., his number of coins will increase by $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 $y$ ).
Note that the bet amount must always be a positive ( $> 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.
输入格式
Each test consists of multiple test cases. The first line contains a single integer $t$ ( $1 \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, x$ and $a$ ( $2 \leq k \leq 30$ , $1 \leq x \leq 100$ , $1 \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.
The single line of each test case contains three integers $k, x$ and $a$ ( $2 \leq k \leq 30$ , $1 \leq x \leq 100$ , $1 \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).
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 $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.
- 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted