Fair Distribution


This is a companion discussion topic for the original entry at https://toph.co/p/fair-distribution

@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)