Numbers
Time limit1sMemory limit1024 MB
Given N positive integers, their total sum, and the products of each adjacent pair, find the integers or report that none exist.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
Vytautas has lived in England for a long time and spends his free time on math puzzles. One day a friend gave him this problem: there are 10 positive integers. Given their sum and the products of the first and second, second and third, ..., ninth and tenth numbers, find the numbers. Vytautas solved it on paper in half an hour.

The next day his friend gave him the same problem with 100 numbers. Then Vytautas realized that it would be simpler to write a program that solves this problem for numbers.
Given , the sum of all numbers, and the products of the first and second, second and third, ..., -th and -th numbers, find the numbers themselves, if such numbers exist.
Input
The first line contains . The second line contains the sum of all numbers. The third line contains the product of the first and second numbers, the fourth line the product of the second and third numbers, and so on, until line , which contains the product of the -th and -th numbers.
Output
If such numbers exist, print TAIP on the first line. Print the first number on the second line, the second number on the third line, and so on, with the -th number on the last line. If there are several correct answers, print any of them.
If no numbers satisfy the data, print NE on the only line.
Constraints
For all tests, . The sum and the products given in the statement are positive integers not exceeding .