Codeforces's problem 151A I've wrote this program in C language , I think it has some problem. Help me out please

170 views Asked by At

151A codeforces link

Here is my code written in C language. It has some problem

#include<stdio.h>
#include<conio.h>
 
int main ()
{
      int n,k,l,c,d,p,nl,np,mm,per,tl,to,sum;
      
      scanf("%d%d%d%d%d%d%d%d",&n,&k,&l,&c,&d,&p,&nl,&np);
      mm = k*l;
      per = mm/nl;
      tl = c*d;
      to = p/np;
      sum=(per,tl,to)/n;
      printf("%d",sum);
      return 0;
}
1

There are 1 answers

1
MikeCAT On

You have to find the minimum value among per, tl, and to and divide that with n instead of just calculating to/n, which you are currently calculating with sum=(per,tl,to)/n;. (per and tl are ignored according to the definition of the comma operator)