/** * Culture * Problem 1, AIC 2003 * Java Sample Solution * Ben Burton */ import java.io.*; class Solution { public static void main(String[] args) throws IOException { // Read in the total number of bacteria. BufferedReader in = new BufferedReader(new FileReader("cultin.txt")); long total = Long.parseLong(in.readLine()); in.close(); // Assume the experiment has been running for 0 days. long start = total; long days = 0; // While the initial number of bacteria is still even, halve // this initial number and add one day to the experiment. while (start % 2 == 0) { start = start / 2; days++; } // Now the initial number of bacteria is odd, so we must have // our solution. BufferedWriter out = new BufferedWriter(new FileWriter("cultout.txt")); out.write(start + " " + days); out.newLine(); out.close(); } }