Integral of a Polynomial
Time limit1sMemory limit256 MB
Parse a degree-at-most-1 polynomial string and print its integral, writing x^2 as xx and the constant of integration as W.
- Level
Easy3 of 10
- Topics
- String, Implementation, Math, Brute force
- Solved
- No attempts yet
Problem
A polynomial is an expression that represents a sum of constant multiples of powers of a variable. For example, is such an expression. One with a single variable is called a polynomial in one variable, written as follows.
Write a program that outputs the integral of a given polynomial in one variable whose degree is at most 1.
Input
The first line gives a polynomial in one variable with degree at most 1. It has at most 2 terms, the variable is always , and the terms are not separated by spaces. Each coefficient is a nonzero multiple of 2 whose absolute value does not exceed 10,000, and each constant is an integer whose absolute value does not exceed 10,000. No two terms have the same degree. However, when the absolute value of a coefficient is 1, the 1 is omitted. The terms are given in order from highest degree to lowest.
Output
Output the integral of the given polynomial in one variable in the same format as the input. The constant of integration is written as W, and is written as xx.
Hint
The integration used in this problem is . ( is the constant of integration) Also, for integrable functions the sum rule holds.