You are not logged in. Please login at www.codechef.com to post your questions!

×

HS08TEST:Getting Wrong Answer

inspite getting satisfactory output my submission is denied by as Wrong answer......somebody help what is that iam not getting.

#include<stdio.h>
int main()

{
int x;float y;

scanf("%d %f",&x,&y);

if(x>0 && y>0)

{

if((x%5)==0 && y>x)

    printf("%.2f\n",y-x-0.50);

    else

        printf("%.2f\n",y);
}
return 0;
}

asked 23 Oct '14, 03:55

wrangler00's gravatar image

3★wrangler00
0114
accept rate: 0%

edited 23 Oct '14, 08:51

topcoder_7's gravatar image

2★topcoder_7
2.9k3153


Hi,

Your code needs to consider the withdrawal charges as well Consider the test case: 5 5.01 Your code will evaluate to successful transaction when infact it should evaluate to false since there is insufficient balance considering the withdrawal charges. :) Hope you can fix the code now.

link

answered 23 Oct '14, 04:08

saurabhgarg's gravatar image

3★saurabhgarg
15634
accept rate: 16%

1) Read carefully the problem statement, 0<= Y <= 2000, you don't need to add the first test " if(x>0 && y>0) ";

2) Your solution isn't correct for every pair (x,y) such that y-x < 0.5, you have to modify this condition " y>x ".

link

answered 23 Oct '14, 04:37

ahmedtai's gravatar image

4★ahmedtai
1464
accept rate: 7%

edited 23 Oct '14, 04:38

Thanks saurabh.........Got it!

link

answered 23 Oct '14, 04:56

wrangler00's gravatar image

3★wrangler00
0114
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,356

question asked: 23 Oct '14, 03:55

question was seen: 616 times

last updated: 23 Oct '14, 08:51