D :: Roots Intervals
Time Limit: 1 Second Memory Limit: 65536 KB
Consider the function f(x)=tan(sin(x))-sin(tan(x))+cos(x)5-0.5 defined on the interval [a,b], and nb≥1 a series of subintervals [xi,xi+1], i=1,nb, where x1=a and xnb+1=b. Find the number of subintervals that contain “observable” roots of f(x). A root in a subinterval [xi,xi+1] is “observable” if the existence of that root can be decided without inspecting the behavior of f(x) for xi<x<xi+1, i.e. a subinterval is a black box and you cannot
compute inside the interval.
Input
The program input is from a text file. Each data set in the file stands for a particular interval [a,b] of f(x) and specifies the limits a, b (real numbers) and the integer number nb of subintervals.
White spaces can occur freely in the input. The input data are correct and terminate with an end of file. An input/output sample for the function f(x)=1-x2 is in the table bellow.
Output
For each data set the program prints the number of subintervals that contain “observable” roots of f(x). Each result is printed on the standard output from the beginning of a line.
Sample Input
-2 2 2 0 100 5 -1 1 1
Sample Output
2 1 1Submit
Source: South Eastern European Regional Contest 2011