View Code of Problem 72

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	double h;
		int n;
	double s=0;
	double t;
	
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		h=h/2.0;
		if(i!=n)
		{
		s=2*h+s;
		}
		
	}
	t=s+1000;
	cout<<setiosflags(ios::fixed)<<setprecision(2)<<h<<" "<<t<<endl;
		
	return 0;
}

Double click to view unformatted code.


Back to problem 72