Problem: https://open.kattis.com/problems/a1paper
Files submitted
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1000111];
int main(){
cin >> n;
for(int i=2; i<=n; i++) cin >> a[i];
int need= 2;
double s= 0, cd= pow(2, -3.0/4), cr= pow(2, -5.0/4);
for(int i=2; i<=n; i++){
s += need/2 * cd;
need-=a[i];
if (need <= 0) break;
need *= 2;
double temp= cr;
cr= cd/2;
cd= temp;
}
if (need > 0) cout<<"impossible";
else cout<<fixed<<setprecision(5)<<s;
}
No comments:
Post a Comment