Why WA for DCP-04 Great!!! The Work Is Done?

Dev Skill archived problems can be discussed here.

Why WA for DCP-04 Great!!! The Work Is Done?

by parthapratimbanik » Fri Jan 06, 2017 9:07 am

I test almost all possible test cases. But there is still WA from verdict. What is the wrong in my answer? Please help me......
Here is my code.

Code: Select all
#include<stdio.h>

int main()
{
    int member,dec,var;
    float decision,d=0,total=0,hr;

      while(scanf("%f",&hr) == 1)
      {
          scanf("%d",&member);
        for(var=1; var<=member; var++)
        {
            scanf("%f",&d);
            total = total + d;
        }

        decision = hr/total;
        dec = (int)decision;
        if(decision > dec )
        {
            printf("Project will finish within %d days.\n",dec+1);
        }
        else
        {
            printf("Project will finish within %d day.\n",dec);
        }
        total=0;
    }
    return 0;
}


Thanks in advance.
 
Posts: 5
Joined: Sun Jan 01, 2017 1:22 am

Re: Why WA for DCP-04 Great!!! The Work Is Done?

by mahrahat » Fri Jan 06, 2017 10:53 pm

Just consider this simple input:
Code: Select all
20 1
10

Your code produces wrong output :(

BTW, there is no need to use float data type. Think over; you can easily solve it using just int variables. :)
Lets
• search through previous topics before posting a new topic
• include link to problem (or at least problem number)
• write code snippets inside [code] [ /code] tags
 
Posts: 48
Joined: Thu Nov 24, 2016 9:11 pm
Location: Bangladesh

Re: Why WA for DCP-04 Great!!! The Work Is Done?

by parthapratimbanik » Sat Jan 07, 2017 12:54 am

At last, it has been got accepted. Thanks a lot. :) :)
 
Posts: 5
Joined: Sun Jan 01, 2017 1:22 am

Re: Why WA for DCP-04 Great!!! The Work Is Done?

by mahrahat » Sat Jan 07, 2017 1:48 am

You are welcome :) :)
Lets
• search through previous topics before posting a new topic
• include link to problem (or at least problem number)
• write code snippets inside [code] [ /code] tags
 
Posts: 48
Joined: Thu Nov 24, 2016 9:11 pm
Location: Bangladesh


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