View Code of Problem 72


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double m = sc.nextDouble();
        int n = sc.nextInt();
        double s = m;
        for (int i = 0; i < n; i++) {
            m = m / 2;
            s = s + 2 * m;
        }
        System.out.println(String.format("%.2f %.2f", m, s-2*m));
    }
}

Double click to view unformatted code.


Back to problem 72