Sphere Online Judge

SPOJ Problem Set (classical)

54. Julka

Problem code: 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]


Added by:Adam Dzedzej
Date:2004-06-08
Time limit:2s
Source limit:50000B
Languages:All except: TECS
Resource:Internet Contest Pogromcy Algorytmow (Algorithm Tamers)
Round II, 2003

hide comments
2010-02-28 00:13:04 Abhishek bhardwaj
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???
2010-02-28 00:10:02 Abhishek bhardwaj
What will be the output for :
100 1
it will
50
50
or
50.50
49.50 ??????
2010-02-03 09:53:12 crazypro
misprint: ... each of The girls have? ...
2009-12-23 10:54:47 Seshadri R
@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.
2009-11-17 12:41:58 Zubaydulla
When i use (itoa, atoi) in my computer there is OK. But in your comp. There is "compilation error".
{my programming language is C++ 5.02;}

Last edit: 2009-11-17 13:18:18
2009-11-03 05:17:56 LgN
GOOD problem for c/c++ users
2009-11-02 04:13:00 Muhamed Mamasali uulu
if the input
340 20
output
180
160
2009-10-15 15:28:36 codebugger
yeah... no worries about large numbers in python.
2009-09-23 05:27:39 Seshadri R
Use python to write the simplest of solutions.

Last edit: 2009-09-23 05:30:21
2009-09-20 21:08:15 Gowtham
i used java to code the above problem. isnt scanner available in java?.because i get a compiler error stating scanner cant be resolved to a type. is the java version that server uses 1.4 or older?.
SPOJ System © 2008-2010 Sphere Research Labs. All Rights Reserved.