View Code of Problem 72

#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    double m, h, s;
    int n;
    cin >> m >> n;
    h = 0;
    s = m;
    for(int i = 1; i <= n; ++i){
        s += 2*h;
        h = m/2;
        m /= 2;
    }
    printf("%.2f %.2f\n",h,s);
 
}

Double click to view unformatted code.


Back to problem 72