Falling Mugs
Time limit1sMemory limit256 MB
Given D, find nonnegative integers n1 and n2 with n2 squared minus n1 squared equal to D, smallest n1 first, or report impossible.
- Level
Easy3 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Susan films falling coffee mugs with a high speed camera. She wants to know how tall the mugs are, but every mug broke during filming, so the video is all she has left.
The camera records 70 frames per second. Count frames from the moment the mug is released, so the release itself is frame 0. By frame the mug has fallen exactly millimeters.
Susan believes one mug is millimeters tall. To check that, she needs two frames and between which the mug fell exactly millimeters, that is, two frames with .
Input
The first and only line contains the distance to be measured, in millimeters ().
Output
Print two non-negative integers and on one line, separated by a space, with .
Several pairs can satisfy the equation. In that case print the lexicographically smallest pair, which is the pair with the smallest . If no such pair exists, print impossible.