31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

small Latin letters, multiplicationsign is omitted (as it is commonin mathematics). The degree (inthis problem it can be equal totwo only) is written withoutspaces right after the variable,for example, a 2 is written as a2.Numerical coefficient (it can notbe larger than 10000) is writtenbefore variable and it is omitted,if it is equal to one (as is acceptedin mathematics).Output. Write zero (0) to thefirst line of the output file, if it isnot possible to expand the polynomialinto multiplicands andnumber K – if it is possible. HereK means the number of ways toExamples of input and output dataInput Output Explanation2abac1ab+cab+ac=a(b+c)2aba26xyzxtx25uy25uz25ut2a2b21aa+b1x+25uy+z+tab+a 2 =a(a+b)xy+zx+tx+25uy+25uz+25ut=(x+25u)(y+z+t)expand the polynomial into multiplicands. In the latter case the second and the thirdlines of the output should contain the first and the second multiplicands of any way ofexpanding.227. Numbers (Run time limit – to 20 sec.; processor Pentium 133 MHz). A setof N (1 ≤ N ≤ 10) integers and one more integer S are given. The task is to determinewhether it is possible to choose such a subset from the given set that the sum of all thenumbers from the subset would be equal to S.Task. Write a program to find such a subset of numbers that their sum would beequal to S. If several possible solutions exist, find any one of them. If it is not possibleto obtain the given sum it must be reported.The input data are entered from the keyboard. Firstly integer S (the given sum) isentered. Then in the separate line N (1 ≤ N≤ 10) integers are entered. Numbers willbe written into one line, separating them by at least one space character.Print the results to the screen in the form of equality. Example:1389 == 1202 + 79 + 100 + 8If it is not possible to obtain the given sum, write IMPOSSIBLE after the equality.Note.: Because the input data are introduced from the keyboard, and the resultsare written to the screen, it is desirable to create comprehensive interface.0a 2 +b 2 =????????45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!