Problem Info
Add name of problem + link to problem here
USACO BRONZE #1- Mixing Milk USACO
My Work
Add commented code here
import java.util.*;
import java.io.*;
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int ac = input.nextInt();
int a = input.nextInt();
int bc = input.nextInt();
int b = input.nextInt();
int cc = input.nextInt();
int c = input.nextInt();
int numofmixed = 0; // initializing the variables for each bucket and their capacities.
while(numofmixed<=100) { // the pours themselves
mix(a, ac, b, bc);
mix(b, bc, c, cc);
mix(c, cc, a, ac);
numofmixed+= 3;
}
System.out.println(a + " " + b + " " + c);
}
public static void mix(int currentamount , int capacityrn, int nextamount, int capacityofnext) {
while(currentamount >= 0 || nextamount<= capacityofnext) {
currentamount--;
nextamount++;
// method to calculate a pour//
}
}
}
Add explanation of code here
So essentially i’ve tried solving this problem using a method in which for each pour i take one “milk” away from the original bucket and add it to the new bucket up until there is 0 in the original bucket or there is maximum milk in the next bucket. Then i looped through all the 100 pours using my method.
What I’ve Tried
Ive tried using the sample input and output to test my solution but so far all my code outputs no matter what i change is “3 4 5” which is the incorrect output.
Question
If someone could help me understand what I’m doing wrong for this problem I would really appreciate that. Thanks
Checklist
See How to ask for help on a problem for more information.
- Include a link to the problem
- Format your post (especially code blocks)
- Include what you’ve tried so far
- Add comments to your code
- Read the debugging module