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: CLOJ F# PERL 6 TECS
Resource:Internet Contest Pogromcy Algorytmow (Algorithm Tamers)
Round II, 2003

hide comments
2010-08-31 11:44:28 Ajil charles
got AC atlast ......

Last edit: 2010-09-01 22:56:38
2010-07-09 10:09:35 Anuj Mahajan
yeee gotcha...AC

ignore test cases that leads to decimal answers..
2010-07-09 08:19:42 Anuj Mahajan
My code seems to work write ..but I am getting WA.

Plz. give some test cases so that I can verify.Hey do we have to consider fraction sol. also

Last edit: 2010-07-09 08:23:02
2010-06-10 15:34:45 王易檀
I have a question.
I check my program a thousand times,it gave me correct answer.(The answer is the same to an other program which uses integer gives).
But I always get WrangAnswer.
Why?
May be my English is too poor(I'm a chinese)...
Help me!!!
F1 F1 F1...

Last edit: 2010-06-10 15:35:17
2010-06-03 08:35:53 weltfremd
EDIT: Okay, I found my errors. Missed a few test cases before that... sorry.

Don't get it. My program seems to produce correct results.
I have even modified it to add and subtract the numbers it produced, to check if this would result in the original values, and it did. Works with numbers up to 101 digits...
Seems all right to me, but I keep getting "wrong answer" :-/

Last edit: 2010-06-03 10:06:55
2010-05-16 14:27:17 Sriram Keerthy Jayaseelan
what should be the output if the total apples is 10 and Klaudia has 1 more than Natalie?
2010-04-09 08:19:04 Alex
Well... The math is easy... but to do it with C++, think about what you do in real life.

Also, think about the specific operations you need (And by what)... no need to generalize everything.

@Abhishek bhardwaj: It is an integer as in a WHOLE number. Not a specific datatype.

Last edit: 2010-04-09 16:18:23
2010-03-21 12:06:11 Mikołaj Piotrowski
stack is one of options
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 ??????
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.