View Code of Problem 72

#include<stdio.h>
#include<math.h>
main()
{
	int m,n;
	double a,b=0;
	scanf("%d %d",&m,&n);
	a=m*1.0/pow(2,n)*1.0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||i==2)
			b+=m;
		else
			b+=m*1.0/pow(2,i-2)*1.0;
	}
	printf("%.2f %.2f\n",a,b);
}

Double click to view unformatted code.


Back to problem 72