Under construction

Still being built. Things may change

Floor Plan

Interview

Time limit1sMemory limit512 MB

Summary
Given n, find non-negative integers m and k with n = m^2 - k^2, or report that no such pair exists.
Level

Easy3 of 10

Topics
Math, Number theory, Brute force, Implementation
Solved
No attempts yet

Problem

You are an architect and you have just been appointed to build a new swimming hall. The organisation behind these plans has acquired funding for a swimming pool and surrounding building as large as they want, but unfortunately they could not find anyone willing to pay for the floor surrounding the pool. They decided to pay for the floor tiles out of their own pocket. Because this has already cost them an arm and a leg, they want you to use all the floor tiles in your proposed plan.

Being an architect, you care for aesthetics. You see it as absolutely vital that both the swimming pool and the surrounding building are perfect squares. This raises an interesting problem: how can you make sure that the square shapes are guaranteed, while still using all the floor tiles the organisation bought?

Given the number of tiles n, find the length of the side of the building m and the length of the side of the pool k such that n = m2 − k2, or print impossible if no suitable m and k exist.

Input

  • One line containing a single integer 1 ≤ n ≤ 109.

Output

Print two non-negative integers m, k such that n = m2 − k2, or print impossible if no such integers exist. If there are multiple valid solutions, you may output any one of them.

Examples3

  1. Example 1

    Input
    7
    
    Expected output
    4 3
    
  2. Example 2

    Input
    10
    
    Expected output
    impossible
    
  3. Example 3

    Input
    15
    
    Expected output
    4 1