Friday 25 March 2016

Solution of LIGHT OJ 1015 :: Brush (I)


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int a,b,c,d,e,f=0,g=0;
    scanf("%d",&a);
    for(b=1; b<=a; b++)
    {
        scanf("%d", &c);
        for(d=1,f=0; d<=c; d++)
        {
            scanf("%d",&e);
            if(e>0) f+=e;
        }
        if(f>=0)
            printf("Case %d: %d\n",b,f);
    }
    return 0;
}

3 comments:

  1. hey brother can you give me the algorithm. i didn't get the logic

    ReplyDelete
  2. Hey Maruf, Here is your explanation.
    1) take a input for test case that's a.
    2) for each test case input a number how many students that's c.
    3) for each student input a number of his dust amount that's e.
    4) add e on a variable f. If e is negative don't add anything.
    5) after completing thous task f is your answer.

    ReplyDelete
  3. ভাই কিছু মনে কইরেন না।
    কিন্তু আপনার কোড বুঝতে গেলে প্রব্লেম হয়।
    a,b,c,d,x,y ভ্যারিয়েবল না ধরে আপনি আরেকটু ভালো ভ্যারিয়েবল(জেমনঃ Total,temp,dust,count) দিয়ে দিতে পারেন আমাদের সুবিধার জন্য।
    আপনার চেষ্টার জন্য আপনাকে ধন্যবাদ ।

    ReplyDelete

Note: only a member of this blog may post a comment.