I tested all the test cases given and various other too and every time I got the right answer but when I submitted it , it showed wrong answer . Could some one please shed some light on my mistakes .
problem: http://www.codechef.com/problems/CIELRCPT
My code(java):
public class CEILRCPT
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int t= input.nextInt();
while(t!=0)
{
int c=0;
double p=input.nextDouble();
for(double i=11.0 ; i>=0.0&&p!=0;i--)
{
double e=Math.pow(2.0,i);
if(p<e)
continue;
else if(p%e==0)
{
p=p-e;
c++;
i++;
}
else
{
c++;
p=p-e;
}
}
System.out.println(c);
t--;
}
}
}