Testing LaTeX on My Posts!
Content
The algorithm I write have the complexity of $O(n)$.
By hand, we can proof that $e^{i\pi}+1 = 0$, therefore God exists.
Nungguin Nasi (TSOC #2 Problem A)
Description
Nungguin Nasi means Waiting for the Rice in Bahasa Indonesia. Nasi Ayam and Nasi Bebek are foods that are commonly served in Indonesia.
There are $$$A$$$ Nasi Ayam and $$$B$$$ Nasi Bebek placed on one place. They are all wrapped up in an indistinguishable food wrap such that you do not know their content. $$$A+B$$$ people, including Pak Dengklek, will queue up for the food. Each person will take one of the remaining food uniformly at random.
Pak Dengklek loves Nasi Bebek. In which position must Pak Dengklek queue up such that the probability Pak Dengklek will receive Nasi Bebek is maximized? If there are multiple positions that maximize the probability, you may output any of them.
Positions are numbered from $$$1$$$ to $$$A+B$$$, where position $$$1$$$ is be the first person to receive the food.
Input Format
The first line is as follows:
T
Then, $$$T$$$ test cases follow. Each test case is given in the following format:
A B
Output Format
For each case, print one line containing one integer representing the position Pak Dengklek must queue up to maximize the probability.
Sample Input
2
3 5
1234 567
Sample Output
7
1800
Constraints
For both easy and hard versions:
- $$$1 ≤ T ≤ 10$$$.
- $$$1 ≤ A+B$$$.
Easy version
- $$$0 ≤ A, B ≤ 100$$$.
Hard version
- $$$0 ≤ A, B ≤ 10^5$$$.
Leave a Comment