Nasty Numbers
InterviewTime limit1sMemory limit128 MB
For each number under 32001, list its factor pairs and check whether the difference of one pair equals the sum of another pair.
- Level
Medium4 of 10
- Topics
- Number theory, Brute force, Implementation, Math
- Solved
- No attempts yet
Problem
A positive integer is called nasty if it has at least two pairs of positive-integer factors such that the difference of one pair equals the sum of the other pair.
For example, 6 is nasty because and . Similarly, 24 is nasty because and .
Given a list of positive integers, determine for each one whether it is nasty.
Input
The first line contains an integer (), the number of integers to test. Each of the following lines contains one positive integer less than .
Output
Print one line for each test value. After the value, print a space followed by is nasty if the value is nasty, or is not nasty otherwise. Keep the same order as the input.