By optimal sol. do we mean minimum number of times to use weight to find the gold coin

and minimum probability the worst probability after weighing k times??

my answers are still lesser than that of correct solution!!! please help !!

#include<stdio.h>

#include<math.h>

int main()

{

long long int n;

long int i,c,k,t;

double p;

scanf("%ld “,&t);

for(i=0;i<t;i++)

{

scanf(”%lld %ld “,&n,&k);

if(n>2){

c=0;

if(n%2==0)

{n=n-1;}

while(n!=0)

{

n=n/2;

c++;}

//printf(”%ld “,c);

if (k>=c)

p=1;

else

{

p=pow(2,(k-c));

}

printf(”%.30lf\n",p);

}

if(n==1)

{

p=1;

printf("%.30lf\n",p);

}

if(n==2)

{

p=0;

printf("%.30lf\n",p);

}

}

return 0;

}