Problems
Roots Intervals
Roots Intervals
Consider the function \textbf{f(x) = tan(sin(x)) - sin(tan(x)) + cos(x)^5 - 0.5} defined on the interval \[\textbf{a}, \textbf{b}\], and \textbf{n*b} ≥ \textbf{1} a series of subintervals \[\textbf{x_i}, \textbf{x_\{i+1\}}\], \textbf{i} = \textbf{1}, \textbf{n*b}, where \textbf{x_1=a} and \textbf{x_\{n*b+1\}=b}. Find the number of subintervals that contain "\textbf{observable}" roots of \textbf{f(x)}. A root in a subinterval \[\textbf{x_i}, \textbf{x_\{i+1\}}\] is "\textbf{observable}" if the existence of that root can be decided without inspecting the behavior of \textbf{f(x)} for \textbf{x_i} < \textbf{x} < \textbf{x_\{i+1\}} i.e. a subinterval is a black box and you cannot, compute inside the interval.
\InputFile
The program input is from a text file. Each data set in the file stands for a particular interval \[\textbf{a}, \textbf{b}\] of \textbf{f(x)} and specifies the limits \textbf{a}, \textbf{b} (real numbers) and the integer number nb of subintervals.
The input data are correct and terminate with an end of file. An input/output sample for the function \textbf{f(x)=1-x^2} is in the table bellow.
\OutputFile
For each data set the program prints the number of subintervals that contain "\textbf{observable}" roots of \textbf{f(x)}. Each result is printed on the standard output from the beginning of a line.
Input example #1
-2 2 2 0 100 5 -1 1 1
Output example #1
1 1 0