Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main(){
- ifstream fin("garland.in");
- ofstream fout("garland.out");
- int n;
- fin >> n;
- double arr[n];
- fin >> arr[0];
- double l = 0, r = arr[0];
- while (r - l > 0.000001){
- arr[1] = (l + r) / 2;
- bool Up = true;
- for (int i = 2; i < n; i++){
- arr[i] = 2 * arr[i - 1] - arr[i - 2] + 2;
- if (arr[i] < 0){
- Up = false;
- break;
- }
- }
- if (Up) r = arr[1];
- else l = arr[1];
- }
- fout.precision(2);
- fout << fixed << arr[n - 1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement