Click Here to go back to the homepage.

Soda Slurper Solution:


import java.util.Scanner;

public class Kattis {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int empty = sc.nextInt() + sc.nextInt();
        int bottles = 0;
        int req = sc.nextInt();
        int total = 0;
        while(empty >= req){
            bottles = empty % req;
            empty /= req;
            total += empty;
            empty += bottles;
        }
        System.out.println(total);
    }
}