I haven't tried milkshake yet. i'll try binomial theorem but can you please
tell why my code is not working


On Sunday, April 8, 2012, Samuel Jawahar wrote:

> use the Binomial theorem to solve this.
> did you solve the milkshake problem?
>
> On Sun, Apr 8, 2012 at 6:28 PM, Sachin Gupta 
> <[email protected]<javascript:_e({}, 'cvml', 
> '[email protected]');>
> > wrote:
>
>> can anyone please check why this code is giving wrong answers. I've
>> checked the solutions each of them uses recursion to solve the problem.
>> http://code.google.com/codejam/contest/32016/dashboard#s=p2
>>
>> import java.io.*;
>> import java.math.*;
>> import java.util.*;
>>
>> public class Main {
>> public static void main (String args[]) throws Exception
>> { BufferedReader in = new BufferedReader(new FileReader("C:\\downloads\\
>> c-small-practice.in"));
>>   BufferedWriter out = new BufferedWriter(new FileWriter("C:\\downloads\\
>> c-output.in"));
>>   int t = Integer.parseInt(in.readLine());
>>   BigDecimal x = new BigDecimal(Math.sqrt(5));
>>   x = x.add(BigDecimal.valueOf(3));
>>   System.out.println(x.toString());
>>   for (int i=1;i<=t;i++)
>>   { int n = Integer.parseInt(in.readLine());
>>     BigDecimal bd ;
>>     bd = x;
>>     bd = bd.pow(n);
>>    // System.out.println(bd);
>>    // System.out.println(bd.toBigInteger());
>>     Formatter fmt = new Formatter();
>>     fmt.format("%03d",bd.toBigInteger());
>>    // System.out.println(fmt);
>>
>>     StringBuilder sb = new StringBuilder(fmt.toString());
>>    // System.out.println(sb.substring(sb.length()-3,sb.length()));
>>     out.write("Case #"+i+": "+sb.substring(sb.length()-3,sb.length()));
>>     out.newLine();
>>   }
>>   out.close();
>>  }
>> }
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to 
>> [email protected]<javascript:_e({}, 'cvml', 
>> '[email protected]');>
>> .
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:_e({}, 'cvml',
>> 'google-code%[email protected]');>.
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to 
> [email protected]<javascript:_e({}, 'cvml', 
> '[email protected]');>
> .
> To unsubscribe from this group, send email to
> [email protected] <javascript:_e({}, 'cvml',
> 'google-code%[email protected]');>.
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to