Help me in solving BMCCP09 problem

My issue

The code is to satisfy the Equation 2X+7Y = N, where X & Y can be ‘0’. Input is only N with ‘t’ number of test cases. if the equation satisfies, it need to give “Yes” as output else “No”.
My code is working fine and giving the required output. Instead the system is is showing the code as incorrect on submission.

My code

// Update the code below to solve the problem

#include <stdio.h>
int main() 
{
	int t;
    scanf("%d",&t);
	
	while(t--)
	{
	    int N;
	    scanf("%d",&N);
	    if (N%2 == 0)
	    {
	        printf("Yes\n");
	    }
	    else if(N%7 == 0)
	    {
	        printf("Yes\n");
	    }
	    else
	    {
	        while(N>=7)
	        {
	            N=N-7;
	        }
	        if (N%2== 0)
	        {
	           printf("Yes\n"); 
	        }
	        else
	        {
	            printf("No\n");
	        }
	    }
	}
	return 0;
}

Learning course: C for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

@mk1910

for n=15
your code will print no 
but its possible to make 15 as 2*4 +7*1=15

Thanks for pointing out, I had already corrected it and that’s working fine.
Thanks a lot.

1 Like