Fair Distribution

Mr. Forhad has X children. One day, on his way home, he bought Y chocolates for his children. He doe…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

@backbenchermmc, don’t paste your answer if you have already solved it.
Remove it or I might report you the next time.

What’s the problem with the second test case?

1 Like

So @touhidur You are the admin here! wow!

:sweat_smile: actually I am just a member. If you want to contact the admin then it would be most likely https://community.toph.co/u/hjr265

instead of ““while(y%3!=0) y++;”” you have to write ““while(y%x!=0) y++;””"

#include <stdio.h>
int main()
{
int choc,ch,i,rem;
scanf(“%d %d”,&ch,&choc);
rem=choc%ch;
if(rem==0)
{
printf(“0”);
}
else {
for(i=0; rem!=0; i++,rem++)
{
if((choc+rem)%ch==0)
{
printf(“%d”,rem);
break;
}
}

}
return 0;

}

What is the problem in this code that it shows wrong answer for second case??
It runs perfectly in my IDE and shows the correct output

x, y = map(int, input().split())
if 0 < x < 150 and 0 < y < 150:
if y % x != 0:
print(((int(y / x) + 1) * x) - y)
elif y % x == 0:
print(“0”)

#include<stdio.h>
int main()
{
int a,b,c,d;
scanf(“%d”,&a);
scanf(“%d”,&b);
c=a%b;
d=a-c;
printf(“%d”,d);
return 0;
}

I can’t find my problem. Please help me to find problem in this programme.

Worked Fine in Python :smiley:

x, y = map(int, input().split())
z = 0

if y % x != 0:
m1 = y % x #3
l1 = x - m1
print(l1)

else:
print(z)