Translate

Views

Sunday, July 3, 2022

Solution Kattis - A1 Paper

Problem: https://open.kattis.com/problems/a1paper

Submission 9105608

IDDATEPROBLEMSTATUSCPULANGTEST CASES
910560822:18:03A1 Paper
Accepted
0.00 sC++
13/13

Files submitted

a1paper.cpp

#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: