Oz and his game-board
Practice
3.5 (239 votes)
Ad Hoc
Mathematics
Open
Approved
Easy
Mathamatics
Problem
28% Success 5209 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Today Oz is playing with his game-board. He has N coins of type-1 and M coins of type-2. Also the game-board has N squares of type-1 and M squares of type-2. In this game Oz must place one coin into each square. After placing all coins Oz will get a score based on his coin placement strategy .

His score calculation is like this : If type-1 square contains a type-1 coin then he will get A points, if type-2 square contains a type-2 coin then he will get B points and in all other cases, he will get C points. Oz's total game score will be sum of scores of all squares. Help Oz to earn maximum game points with his game-board.

Input :

The first line contains the number of test cases T .

Each test case consists of five space separated integers - \(N, M, A, B\) and C.

Output :

For each test case output maximum game points that Oz can earn.

Constraints :

\(1 \le T \le 100\)

\(1 \le N, M \le 10\)9

\(-10\)4 \( \le A, B, C \le 10\)4

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
96 votes
Tags:
ReadyMathematicsApprovedEasyMathamatics
Points:20
4 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Points:20
16 votes
Tags:
Basic ProgrammingOpenApprovedEasyMathamatics