View Code of Problem 72

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

Double click to view unformatted code.


Back to problem 72