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
weltfremd:
2010-06-03 06:35:53
EDIT: Okay, I found my errors. Missed a few test cases before that... sorry.
|
|
.:: Jarv1s ::.:
2010-02-27 23:13:04
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"-What does it means if max no of apples are 10^100.Why problem statement says it as integer??? |
|
Seshadri R:
2009-12-23 09:54:47
@Zubaydulla: atoi is a standard function; itoa is not. Hence, you got compilation error. By the way, what is C++ 5.02? You may be referring to a compiler from a specific vendor, who has non-standard extensions (like itoa) and hence your program worked on your home turf and failed on a neutral terrain. |
|
Seshadri R:
2009-09-23 03:27:39
Use python to write the simplest of solutions. Last edit: 2009-09-23 03:30:21 |
|
Brian Bi:
2009-06-28 16:10:27
If the problem statement does not mention impossible test cases, you should assume that they do not exist. |
|
Drew Saltarelli:
2009-06-25 16:38:11
are there any cases where it will be impossible for Klaudia to have x number of apples more than Natalia? |
|
Srinivas Iyengar:
2009-02-21 04:00:11
For C/C++ Users, The Input is really Large(<10^100), Requires Implementation that handles that large a number. |
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 |