Division Expression
BOI 2000 Day 2 Problem 1Division ExpressionDivision expression is an arithmetic expression of the form x1/x2/x3/.../xk where xi is a positive integer, for i, (1<=i<=k). Division expression is evaluated from the left to the right. For instance the value of the expression 1/2/1/2 is 1/4. One can put parentheses into expression in order to change its value. For example the value of the expression (1/2)/(1/2) is 1. We are given a division expression E. Is it possible to put some parentheses into E to get an expression E' whose value is an integer number. TaskWrite a program that for each data set from a sequence of several data sets:
InputThe first line of the file DIV.IN contains one positive integer d, (d<=5). This is the number of data sets. The data sets follow. The first line of each data set contain an integer n, (2<=n<=10000). This is the number of integers in the expression. Each of the following n lines contains exactly one positive integer not greater than 1,000,000,000. The ith number is the ith integer in the expression.OutputFor each i,(1<=i<=d) your program should write to the ith line of the output file DIV.OUT one word YES, if the ith input expression can be transformed into an expression whose value is an integer number, and the word NO in the other case.Sample Input2 4 1 2 1 2 3 1 2 3 Sample OutputYES NO RemarkTime limit for each test: 2 sSubmitStatistics |