Saturday, August 25, 2018

  • Problem Description

    ") A new Canteen is opened in IIST Campus. Since today is the opening day, the canteen owner is giving an offer, in which every student must purchase 5 items each each of cost <1,000. The offer is, student can pay any amount, but the amount paid is the result of four binary operations ( +, - , *, / ) between the cost of five items. Now your taks is to help the student save his money. NOTE: No binary operator is to be repeated.
    Input
    Input consists of five integers each seperated by spaces.
    Output
    Your output must contain an ineger satisfying the above conditions
    "
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a[5],i,total;
      float sum=0,sub=0,mul=1,div=1;
      for(i=0;i<5;i++)
      {
        scanf("%d",&a[i]);
      }
      for(i=0;i<5;i++)
      {
        sum=sum+a[i];
      }
      for(i=0;i<5;i++)
      {
        sub=a[i]-sub;
      }
      for(i=0;i<5;i++)
      {
        mul=mul*a[i];
      }
      for(i=0;i<5;i++)
      {
        div=a[i]/div;
      }
      total=sum+sub+mul+div;
      if(total<1000)
      {
        printf("1");
      }
      else
      {
        printf("2");
      }

    return 0;
    }
  • Test Case 1

    Input (stdin)
    2 3 4 5 6
    
    
    Expected Output
    1
  • Test Case 2

    Input (stdin)
    5 9 6 4 7
    
    
    Expected Output
    2

1 comment: