The Blessing
Practice
3.4 (132 votes)
Ready
Mathematics
Open
Approved
Easy
Mathamatics
Problem
72% Success 2938 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

In a village far far away, lived a farmer named Zico. He was finding it difficult to make his two ends meet and hence, approached the god of grains, Azure. Azure granted him a blessing:

"I shall grant thou P units of food initially . After every year, thou shall come to me and the food units shall increase by a value M i.e P+M, P+M+M, ... and so on. But remember, every year the population of your village shall multiply by a factor of '2' and you must divide the food evenly among all villagers."

Zico returns back , calculates how many total units of food will he be able to secure for himself, if he becomes immortal and keeps going to Azure till the end of time and space, as we know it.

Note:
-Assume Zico is the only one in the village i.e Initial Population=1

INPUT
First line contains an integer T. T testcases follow.
Each test case contains two space-separated integers P, M

OUTPUT
For each test case, output the answer in a new line.

Constraints
1 ≤ T ≤ 105
0 ≤ P ≤ 1010
1 ≤ M ≤ 1010

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
Tags:
Easy
Points:20
31 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Points:20
8 votes
Tags:
Basic ProgrammingMathematicsOpenApprovedEasyMathamatics