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...
|
|
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.
|
|
karan173:
2011-10-30 18:28:13
how r u guys handling such large nos.?
|
|
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
|
|
hbm:
2011-06-29 13:48:16
Anyone who has an accepted solution, please say what your code gives for 33 and 4!
|
|
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 |