LightOJ 1227 – Boiled Eggs

Problem:-http://www.lightoj.com/volume_showproblem.php?problem=1227

Solution :-

  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,i,k,a,b,c,d[1000],t=1;
  5.     scanf(“%d”,&n);
  6.     while(t<=n)
  7.     {
  8.         int s=0;
  9.         scanf(“%d %d %d”,&a,&b,&c);
  10.         i=1;
  11.         while(i<=a)
  12.         {
  13.             scanf(“%d”,&d[i]);
  14.             i++;
  15.         }
  16.         k=0;
  17.         for(i=1;i<=&& i<=b;i++)
  18.         {
  19.             s+=d[i];
  20.             if(s>c)
  21.             break;
  22.             k++;
  23.         }
  24.         printf(“Case %d: %dn,t,k);
  25.         t++;
  26.     }
  27.     return 0;
  28. }
At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .

Posted by Shipu Ahamed

Leave a Reply