My issue
My code
// Update the code below to solve the problem
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int N, K;
scanf("%d%d",&N,&K);
if(N<K||(N%2==0&&K%2==0&&N==K))
{
printf("\nNO");
}
else
{
printf("\nYES");
}
}
return 0;
}
Learning course: Solve Programming problems using C
Problem Link: CodeChef: Practical coding for everyone
@nitheesha39
Your logic is not right
suppose i have to fill n=5 boxes what will be the minimum number of balls req to give each box at least one ball and number of balls in each boxes are distinct.
O O O O O
O O O O
O O O
O O
O
i will distribute in this manner to have minimum balls.
which will be (K*(K+1))/2;
@dpcoder_007
The given code has a test case as n=30 and k=3; the logic you gave me is not working with that case.
@nitheesha39
n=30 and k=3 boxes ,how much minimum u needed to make all boxes distinct its (k * (k+1))/2 that is 6 and u have 30 balls which is greater than 6 so the answer will be yes u can make .
Like for this case i’ll go like this
O
OO
OOO…(and rest 30-6 balls too in this box).
hope u got the logic now.
1 Like
Now I understood. Thank you for explaining this.
1 Like