JULKA - Julka


Julka surprised her teacher at preschool by solving the following riddle:

Klaudia and Natalia have 10 apples together, but Klaudia has two apples more than Natalia. How many apples does each of he girls have?

Julka said without thinking: Klaudia has 6 apples and Natalia 4 apples. The teacher tried to check if Julka's answer wasn't accidental and repeated the riddle every time increasing the numbers. Every time Julka answered correctly. The surprised teacher wanted to continue questioning Julka, but with big numbers she could't solve the riddle fast enough herself. Help the teacher and write a program which will give her the right answers.

Task

Write a program which

  • reads from standard input the number of apples the girls have together and how many more apples Klaudia has,
  • counts the number of apples belonging to Klaudia and the number of apples belonging to Natalia,
  • writes the outcome to standard output

Input

Ten test cases (given one under another, you have to process all!). Every test case consists of two lines. The first line says how many apples both girls have together. The second line says how many more apples Klaudia has. Both numbers are positive integers. It is known that both girls have no more than 10100 (1 and 100 zeros) apples together. As you can see apples can be very small.

Output

For every test case your program should output two lines. The first line should contain the number of apples belonging to Klaudia. The second line should contain the number of apples belonging to Natalia.

Example

Input:
10
2
[and 9 test cases more]

Output:
6
4
[and 9 test cases more]


hide comments
MR. BEAN : 2011-12-23 08:08:14

take care of odd numbers...
got WA in C and AC with the same code in C++ !!!

sikandar: 2011-12-19 13:51:44

in JAVA use BigInteger for large number, i got AC.

nixeagle: 2011-11-02 02:26:03

@ksb: If you are using C++ and or C you need to write your own arbitrary precision integer arithmetic code. Or you can use some other language that has it built in.

@Abhishek bhardwaj: The problem uses the term 'Integer' in the mathematical sense. That is we are talking about mathematical objects, not machine words.

@Abhishek Parthasarathy: Your comment is what clued me into what was wrong with my submission. There are cases in this problem where the difference of apples is odd. That is when given 3232 apples and klaudia having 1233 more... the result is klaudia=2232, Natalia=999. NOT Natalia=1000.

Fixing the above gave me AC. (Hope this comment is acceptable and whatnot, if a bit long. I tried hard to avoid giving too much info!)

karan173: 2011-10-30 18:28:13

how r u guys handling such large nos.?
since wid double, u loose precision!

flareneos: 2011-10-10 07:47:38

BigInteger <3

multisystem: 2011-08-18 04:56:37

I got it AC with integer operations only. No need to handle cases such 33,4. My code produces 18,14 anyway.

Onur Yirmibeº: 2011-07-21 08:56:08

Solution of
33 & 4 -> 14.5 & 18.5
4 & 1 -> 1.5 & 2.5
8 & 3 -> 2.5 & 5.5

These are the answers for these examples so there is no integer solution if you are looking for that.

hbm: 2011-06-29 13:48:16

Anyone who has an accepted solution, please say what your code gives for 33 and 4!

Many have asked, in these comments and in the forum, and I don't see a clear answer. I've tried fractions; rounding so that the total is correct but the difference is wrong; and rounding so that the difference is correct but the total is wrong.

Thanks.

Last edit: 2011-07-07 14:44:19
ankitsablok89: 2011-06-28 09:38:18

@Dark_Night the answer will be rounded of in that case if the total number of apples is even and the number of apples Klaudia has greater is even or vice versa so just go by the statement

Dark_night: 2011-05-27 14:27:57

please solve if input is 33 and 4?????????????


Added by:Adam Dzedzej
Date:2004-06-08
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET
Resource:Internet Contest Pogromcy Algorytmow (Algorithm Tamers)
Round II, 2003