Nasty Numbers

Interview

Time limit1sMemory limit128 MB

Summary
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 6=6×1=2×36 = 6 \times 1 = 2 \times 3 and 6−1=2+3=56 - 1 = 2 + 3 = 5. Similarly, 24 is nasty because 24=12×2=6×424 = 12 \times 2 = 6 \times 4 and 12−2=6+4=1012 - 2 = 6 + 4 = 10.

Given a list of positive integers, determine for each one whether it is nasty.

Input

The first line contains an integer TT (T≤20T \le 20), the number of integers to test. Each of the following TT lines contains one positive integer less than 3200132001.

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.

Examples1

  1. Example 1

    Input
    4
    6
    24
    30420
    10078
    
    Expected output
    6 is nasty
    24 is nasty
    30420 is nasty
    10078 is not nasty