Great the work is done

Dev Skill archived problems can be discussed here.

Great the work is done

by arabin » Sun Nov 06, 2016 3:25 pm

This is my code for the problem Great the work is done. i tested this code with uDebug and it shows output accepted. But still it shows wrong answer in DevSkill site. What is the problem can anyone tell me please.

Code: Select all
#include <stdio.h>
#include <math.h>
struct data {
    int hoursTake;
    int totalMebers;
};

int main() {
 
   
    struct data input;
   
    scanf("%d %d", &input.hoursTake, &input.totalMebers);
   
    int sum = 0;
   
    if (input.hoursTake<=100 && input.totalMebers<=100) {
       
        for (int i = 0; i<input.totalMebers; i++) {
            int individualH;
            scanf("%d",&individualH);
            if (individualH<=24) {
                sum += individualH;
            }
        }
       
    }
   
    double ans = (double)input.hoursTake/sum;
   
    int finalAns = (int)ceil(ans);
   
    if (finalAns>1) {
         printf("Project will finish within %d days.\n", finalAns);
    }
    else{
         printf("Project will finish within %d day.\n", finalAns);
    }
    return 0;
}

 
Posts: 28
Joined: Sat Aug 06, 2016 11:02 pm

Re: Great the work is done

by froghramar » Sun Nov 06, 2016 7:08 pm

This problem has multiple test cases. Recheck the sample I/O provided on devskill.
User avatar
 
Posts: 33
Joined: Thu Jul 28, 2016 8:14 am
Location: Amar Ekushey Hall, University of Dhaka

Re: Great the work is done

by arabin » Sun Nov 06, 2016 9:29 pm

yes i saw it has multiple testCase. but how many testCases they have not mentioned. how how many testCase should i take ?
 
Posts: 28
Joined: Sat Aug 06, 2016 11:02 pm

Re: Great the work is done

by devskill » Sun Nov 06, 2016 10:52 pm

There is a concept called end of file or in short EOF. This helps you to determine when the input ends.

For example the code below:

Code: Select all
#include <stdio.h>
int main()
{
    int c;
    while ((c = getchar()) != EOF)
    {
        /*
        ** Do something with c, such as check against '\n'
        ** and increment a line counter.
        */
    }
}


Please do some search in google with terms : How to use EOF to run through a text file in C

you may learn how to do this.
User avatar
Site Admin
 
Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm

Re: Great the work is done

by arabin » Sun Nov 06, 2016 11:35 pm

thank you i got it now
 
Posts: 28
Joined: Sat Aug 06, 2016 11:02 pm


Who is online
Users browsing this forum: No registered users and 1 guest
cron