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.

44226. Expanding Polynomial Into Multiplicands. (Runtime limit – to 3 sec.;processor Pentium 133 MHz). From the course of mathematics you know how toexpand expressions into multiplicands; for example, the expression ab+ac+3b+3ccan be expanded as a product of two multiplicands:ab+ac+3b+3c = a(b+c)+3(b+c) = (a+3)(b+c)In general, decomposition into multiplicands is rather complicated problem, but inspecial cases (as it will be presented below in the task) it can be solved rather easily.The polynomial of class A will be called the polynomial with the following properties:• 2nd degree is a polynomial;• has two or more variables;• it is reduced (i.e. similar terms are collected);• all the monomials have integer positive coefficients;• the coefficients by squares are equal to one;The polynomial of class B will be called the polynomial with the following properties:• 1st degree is a polynomial;• has two or more variables;• it is reduced (i.e. similar terms are connected);• all the monomials have integer positive coefficients;Examples of the polynomials of class A:2ab+4ac+af+3ef+cea 2 +b 2 +bcxyExamples of the polynomials of class B:3a+f+2ga+78bxExamples of expressions that do not belong to the class A:ab+b The monomial b is not of the second degreeab-bc The coefficient before bc is not positiveab+abc The monomial abc is not of the second degreeab+1,5xy The coefficient before xy is not integer2a 2 +b 2 The coefficient before a 2 is not equal to oneExamples of expressions that do not belong to class of polynomials B:b+b The polynomial is not reducteda-c The coefficient before c is not positiveab+c The monomial ab is not of the first degreeTask. Write a program to expand the polynomial of class A into product of twopolynomials of class B.Input. There is one number N (N

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

Saved successfully!

Ooh no, something went wrong!