nov challenge 2018 MAGICHF2

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;
}

Yes, the requirement is a little hard to understand. The probability you’re after is the worst case value, if you complete your weighings and then have to guess which coin is right.

Basically all you get from each weighing is a true/false report on whether the coins you weighed contain the true coin.

The first weighing is different from subsequent weighings, because at that stage you know nothing about any of the coins. After that you have a stock of known-bad coins.