Back
Close

Sum and product

Statement

 Goal

You must find the value of two positive integers A and B.
For that, you will receive two other numbers:
S, the sum of A and B
P, the product of A and B
Output A and B separated by a space, with A smaller or equal to B.
Input
Line 1: An integer S which is equal to A + B.
Line 2: An integer P which is equal to A * B.
Output
One line: 2 integers A and B separated by a space.
Constraints
AB
0 ≤ A,B ≤ 1000
Example
Input
5
6
Output
2 3

Game modes
FastestShortest

Test cases
Simple case Test
Input
5 6
Output
2 3

Simple case Validator
Input
6 8
Output
2 4

Same numbers Test
Input
8 16
Output
4 4

Same numbers Validator
Input
12 36
Output
6 6

Product 0 Test
Input
24 0
Output
0 24

Product 0 Validator
Input
18 0
Output
0 18

Both 0 Test
Input
0 0
Output
0 0

Both 0 Validator
Input
0 0
Output
0 0

Sum > Product Test
Input
42 41
Output
1 41

Sum > Product Validator
Input
56 55
Output
1 55

Big numbers Test
Input
107 2730
Output
42 65

Big numbers Validator
Input
65 966
Output
23 42

Bigger numbers Test
Input
1652 676500
Output
750 902

Bigger numbers Validator
Input
1390 466641
Output
567 823

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants