Problem Description
One day, God Sheep would like to play badminton but he can’t find an opponent. So he request Mr. Panda to play with him. He said: “Each time I win one point, I’ll pay you $X$ dollars. For each time I lose one point, you should give me $Y$ dollars back.” God Sheep is going to play $K$ sets of badminton games. For each set, anyone who wins at least 11 points and leads by at least 2 points will win this set. In other words, normally anyone who wins 11 points first will win the set. In case of deuce (E.g. 10 points to 10 points), it’s necessary to lead by 2 points to win the set. Mr. Panda is really good at badminton so he could make each point win or lose at his will. But he has no money at the beginning. He need to earn money by losing points and using the money to win points. Mr. Panda cannot owe God Sheep money as god never borrowed money. What’s the maximal number of sets can Mr. Panda win if he plays cleverly?
Input
The first line of the input gives the number of test cases, $T$. $T$ test cases follow. Each test case contains 3 numbers in one line, $X$, $Y$ , $K$, the number of dollars earned by losing a point, the number of dollars paid by winning a point, the number of sets God Sheep is going to play. $1 \leq T \leq 10^5.$ $1 \leq X, Y, K \leq 1000.$
Output
For each test case, output one line containing “Case #x: y”, where $x$ is the test case number (starting from 1) and $y$ is the maximal number of sets Mr. Panda could win.
#include<set> #include<map> #include<queue> #include<cmath> #include<string> #include<cstring> #include<cstdio> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int maxn = 1e2 + 10; const int mod = 1000000007; int main() { int t, t1 = 1; scanf("%d", &t); while(t--) { int x, y, k; scanf("%d%d%d", &x, &y, &k); if(x > y) printf("Case #%d: %d\n", t1++, k); else printf("Case #%d: %d\n", t1++, 11 * k * x / (11 * y + 2 * x)); } return 0; }