Back
Close

Iornic vs Titanic

Statement

 Goal

In a village, two fighters a and b want to be the king of the village, but both cannot be the king, that's why they started a fight.

There will be r rounds, each round a will hit b and decrease his health by a_1, b hits a and decreases his health by b_1

But the fun fact is that, if a hits b or b hits a, the attacker will get health according to this
a_1 / 2
or
b_1 / 2
Note: The health to add is the rounded down value.

After r rounds, your task is to find the winner and print his remaining health too.

Note: a and b are the health of the players, b will hit a first, and also this is confirmed that any of them will be the winner in the end.

Note: Player B or Player A's health can be more than their initial values after the r rounds.

If any of the player's health get below 0 or equal to 0, the fight ends, print the winner and his remaining health.
Input
Line 1: An Integer r, the number of rounds to be played
Line 2: Four space-separated integers, a the health of player A, b the health of player B, a_1 player B's health will be decreased by this number, b_1 player A's health will be decreased by this number.
Output
If the winner is player A, print A and his health (Space separated) , otherwise print B and his health (Space separated) .
Constraints
1 <= r <= 10
30 <= a b <= 500
10 <= a_1 b_1 <= 75
Example
Input
5
450 500 65 35
Output
A 435

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
5 450 500 65 35
Output
A 435

Validator 1 Validator
Input
8 350 300 25 13
Output
A 342

Test 2 Test
Input
9 250 400 10 60
Output
B 510

Validator 2 Validator
Input
10 340 323 30 30
Output
A 190

Test 3 Test
Input
3 430 250 35 75
Output
B 256

Validator 3 Validator
Input
1 30 35 20 10
Output
A 30

Test 4 Test
Input
6 489 490 75 74
Output
A 267

Validator 4 Validator
Input
7 365 360 35 65
Output
B 339

Solution language

Solution

Stub generator input