Drawing
InterviewTime limit1sMemory limit256 MB
Given n brightness values, decide whether some real a and positive real b make floor(a + b*k) equal every value.
- Level
Medium5 of 10
- Topics
- Math, Brute force, Implementation, Binary search
- Solved
- No attempts yet
Problem
This semester too many students signed up for Drawing, and the professor in charge can no longer handle them. So each student completes a drawing assignment, scans it, and submits it. Large pictures take too long to grade, so color information is recognized using only brightness, approximated as a natural number between 0 and 255.
The first class was simply about filling a sketchbook by drawing lines, and every student whose brightness exceeded 200 passed.
The second class practices brightness gradation. The assignment is to divide the sketchbook into cells and draw lines so that the brightness forms an arithmetic progression. Because the scan approximates it, the passing condition is that for some real number and positive real number , the brightness of the -th cell satisfies . Here means rounding down. You must write the grading program.
That is, given the brightness of cells, write a program that decides whether there exist a real number and a positive real number such that for every natural number between and , the brightness of the -th cell satisfies .
Input
The first line gives the number of cells . satisfies .
The second line gives the brightness values , separated by spaces. Each brightness satisfies .
Output
If the condition holds, print "pass"; otherwise print "fail", without the quotation marks.