knightnemo commited on
Commit
0242fe6
·
verified ·
1 Parent(s): 3e66834

Upload code_segments/segment_397.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_397.txt +27 -0
code_segments/segment_397.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Man, this Genshin boss is so hard. Good thing they have a top-up of $6$ coins for only $ \$4.99$. I should be careful and spend no more than I need to, lest my mom catches me...
2
+
3
+ You are fighting a monster with $z$ health using a weapon with $d$ damage. Initially, $d=0$. You can perform the following operations.
4
+
5
+ * Increase $d$ — the damage of your weapon by $1$, costing $x$ coins. * Attack the monster, dealing $d$ damage and costing $y$ coins.
6
+
7
+ You cannot perform the first operation for more than $k$ times in a row.
8
+
9
+ Find the minimum number of coins needed to defeat the monster by dealing at least $z$ damage.
10
+
11
+ The first line contains a single integer $t$ ($1\le t\le 100$) — the number of test cases.
12
+
13
+ The only line of each test case contains 4 integers $x$, $y$, $z$, and $k$ ($1\leq x, y, z, k\leq 10^8$) — the first operation's cost, the second operation's cost, the monster's health, and the limitation on the first operation.
14
+
15
+ For each test case, output the minimum number of coins needed to defeat the monster.
16
+
17
+ In the first test case, $x = 2$, $y = 3$, $z = 5$, and $k = 5$. Here's a strategy that achieves the lowest possible cost of $12$ coins:
18
+
19
+ * Increase damage by $1$, costing $2$ coins. * Increase damage by $1$, costing $2$ coins. * Increase damage by $1$, costing $2$ coins. * Attack the monster, dealing $3$ damage, costing $3$ coins. * Attack the monster, dealing $3$ damage, costing $3$ coins.
20
+
21
+ You deal a total of $3 + 3 = 6$ damage, defeating the monster who has $5$ health. The total number of coins you use is $2 + 2 + 2 + 3 + 3 = 12$ coins.
22
+
23
+ In the second test case, $x = 10$, $y = 20$, $z = 40$, and $k = 5$. Here's a strategy that achieves the lowest possible cost of $190$ coins:
24
+
25
+ * Increase damage by $5$, costing $5\cdot x$ = $50$ coins. * Attack the monster once, dealing $5$ damage, costing $20$ coins. * Increase damage by $2$, costing $2\cdot x$ = $20$ coins. * Attack the monster $5$ times, dealing $5\cdot 7 = 35$ damage, costing $5\cdot y$ = $100$ coins.
26
+
27
+ You deal