Back
Close

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

You are young Gauss, and your teacher wrote the natural numbers from 1 to N on the board.
When the class went out for lunch, two numbers mysteriously disappeared!

All that remains are:

• the sum of the remaining natural numbers

• the sum of their squares

Your task is to find the two missing natural numbers.
Input
Line 1: An integer N representing the largest natural number written on the board.
Line 2: An integer S — the sum of the remaining natural numbers.
Line 3: An integer Q — the sum of squares of the remaining natural numbers.
Output
Line 1: Two space-separated integers — the missing natural numbers, in ascending order.
Constraints
2 ≤ N ≤ 1 000 000
All given values fit within 64-bit signed integers.
Example
Input
10
44
312
Output
3 8

A higher resolution is required to access the IDE