COLLABRAINS-Editorials 3

PROBLEM CODE
VIEW2003

PROBLEM LINK:
https://www.codechef.com/QTCC2020/problems/VIEW2003

DIFFICULTY:
Easy

PREREQUISITES:
math

PROBLEM :
Calculate the number of bags of fertilizer, lime, and grass seed needed based on the square footage of the lawn to be treated and seeded.

EXPLANATION:
All data is on a single line. The first integer indicates how many integers follow.For each lawn, output the number of bags of fertilizer, the number of bags of lime, and the number of bags of grass seed – in that order. Output the number of bags, followed by the word BAG(S) and then the item type. All letters are upper case. Include some white space between outputs. The output is to be formatted exactly like that for the sample output given below.The area value is in the range 1…30000.You must buy whole bags, and you cannot buy less than the square footage requires for coverage.Coverage Factors:50# bag fertilizer covers 5000 square feet,40# bag of lime covers 2000 square feet,5# bag of grass seed covers 1000 square feet.

SOLUTIONS:

Summary

#include<stdio.h>
int main ()
{
int dataset;
scanf ("%d", &dataset);

while ( dataset-- ) {
    int input;
    scanf ("%d", &input);

    int count = input / 5000;

    if ( input % 5000 )
        count++;

    printf ("%d BAG(S) FERTILIZER\n", count);

    count = input / 2000;

    if ( input % 2000 )
        count++;

    printf ("%d BAG(S) LIME\n", count);

    count = input / 1000;

    if ( input % 1000 )
        count++;

    printf ("%d BAG(S) SEED\n\n", count);
}

return 0;

}

Feel free to Share your approach.Suggestions are welcomed as always had been. :slight_smile: