When i try to solve the "Bathroom Stalls" problem, I reach to this solution
(code in java below):
public static String ProblemC(int caseNumber, Scanner in) {
String result = "Case #" + caseNumber + ": ";
double Ls = 0, Rs = 0;
if (in.hasNext()) {
long N = in.nextLong(), K = in.nextLong();
if(K < N)
{
double po = 1, powerof = 2, lastPow = 1;
while (powerof <= K)
{
po++;
lastPow = powerof;
powerof = Math.pow(2, po);
}
double dx = Math.floor ((N-K) /lastPow) + 1;
println("power:" + po + " ;" +powerof + " ;" + lastPow + "
(N-K)" + (N-K) + "dx:" + dx);
Ls = dx/2; Rs = Ls;
if(dx%2==0) Rs--;
}
}
result += (long)Ls + " " + (long)Rs;
println(result);
return result + "\n";
}
It passed the 2 small dataset (all correct), but not the large one. I know my
method has some problems, but i can't find it. So i post here, and hope someone
can help me!
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/0454aaf1-396c-4615-9393-f88401861492%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.