CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Challenge 2013
    • May Cook-Off 2013
    • May Challenge 2013
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • Campus Chapters
    • Host your Contest
    • Go for Gold
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
    • Top Contributors on Discuss
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Practice(easy) » ATM

ATM

Problem code: HS08TEST

  • Submit
  • All Submissions

All submissions for this problem are available.

Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 $US.

Calculate Pooja's account balance after an attempted transaction.

Input

Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to withdraw.

Nonnegative number 0<= Y <= 2000 with two digits of precision - Pooja's initial account balance.

Output

Output the account balance after the attempted transaction, given as a number with two digits of precision. If there is not enough money in the account to complete the transaction, output the current bank balance.

Example - Successful Transaction

Input:
30 120.00

Output:
89.50

Example - Incorrect Withdrawal Amount (not multiple of 5)

Input:
42 120.00

Output:
120.00

Example - Insufficient Funds

Input:
300 120.00

Output:
120.00

Author: admin
Date Added: 1-12-2008
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, FORT, HASK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

anomer @ 4 Jul 2009 02:07 AM

WTF? Getting 'Wrong Answer' all the time, can't see why.

sid_chilling @ 5 Jul 2009 07:20 PM

something very strange is happening here. I just converted a successful submission in C to Java and it gave "Wrong Answer"... what is going on?

i0exception @ 6 Jul 2009 05:12 PM

You can view other successful java solutions to figure out your mistake.

calvin @ 16 Jul 2009 11:29 PM

how can we know for which test cases it is giving wrong answer?

calvin @ 16 Jul 2009 11:38 PM

omg what kind of dumb test set it is using?? :( i'm losing interest :(

admin 2 @ 17 Jul 2009 12:03 AM

@ramki A lot of users have got an ACC on this problem. You need to debug your code or rethink your algorithm if you are getting a wrong answer.

rockinneal @ 29 Jul 2009 02:45 AM

Phew,finally Done!!

doshidevang @ 3 Aug 2009 08:42 AM

?why m getting wrong ans?? even though logic and program is 100 % correct mr. admin plz put light on it...

admin 2 @ 3 Aug 2009 06:13 PM

The accepted submissions are accessible. You may want to run them on random test data and check if your outputs match.

nishantb @ 13 Aug 2009 07:29 AM

is my code wrong if it gives 30 90 as o/p for the i/p 30.00 120.00

nishantb @ 13 Aug 2009 07:38 AM

plz will ny one see my solution..m a newbie..need help..

nishantb @ 13 Aug 2009 07:47 AM

my code works f9 with dev c 4.9.9.2 whereas the site says compile error someone plz help

nishantb @ 13 Aug 2009 07:49 AM

atleast tell which compiler is being used...nyone out there

nighthunter33 @ 13 Aug 2009 04:09 PM

I'm confused too as to why im getting a "wrong answer" response as my code appears to produce the exact same output for each of the examples given. Any help would be very welcome thanks

admin 2 @ 13 Aug 2009 06:45 PM

@Nilesh @Bob All solutions for this problem are available. Why don't you take any of the accepted submissions and try running them against some random test cases and check if the output matches.

@Nilesh Please don't spam the comments' section.

admin 2 @ 13 Aug 2009 06:48 PM

@Nilesh For what compilers we use and other questions, please read http://blog.codechef.com/2009/06/29/frequently-asked-questions/ and http://www.codechef.com/help

prattsishunk @ 16 Aug 2009 09:57 PM

hey...what compile error man???
i've successfully compiled this program...
but still its showing me compile error...

admin 2 @ 16 Aug 2009 10:10 PM

http://www.codechef.com/help/ Search for a sample solution in java on this page. Also, if you have other questions, you can check out http://blog.codechef.com/2009/06/29/frequently-asked-questions/ You are getting a compile error because the name of your class is not Main.

vikas_singla86 @ 17 Aug 2009 12:29 PM

I am getting run time error saying (NZEC) . I help, its wriiten non zero exit code. My code is in java. Its running successfully in my system. class name is Main. Please help.

admin 2 @ 17 Aug 2009 02:59 PM

There could be a problem with the I/O. You might want to check that out.

vikas_singla86 @ 17 Aug 2009 03:43 PM

yeah got it thanks .. problem was with io only.

admin 2 @ 17 Aug 2009 03:58 PM

You are welcome :)

jpgargoyle @ 18 Aug 2009 07:36 AM

Hi. Why is the time limit on this problem 1 second and I've seen accepted entries with a time of more than 2 seconds?
Is there different time limits for different languages?
I'm asking because I'm usung python and execution time is an issue.

Thanks a lot :)

I have submitted two answers

satish1984 @ 21 Aug 2009 11:04 AM
I have submitted two answers both seem to be wrng , so i looked into the solution , they are passing the same inputs as i m ...not getting my mistake with this...

10 10.25

leppyr64 @ 21 Aug 2009 11:42 AM
10 10.25

wat the hell is gng

prattsishunk @ 21 Aug 2009 09:59 PM
wat the hell is gng on...?? its not showing the o/p...i mean its showing "Running.." for cont i hr i am gettin the same thing.. wer's d prob..??

You can check the status of

i0exception @ 21 Aug 2009 11:54 PM
You can check the status of your submission on the My Submissions page. If you keep having errors, check out the FAQ and the help section for more information on how to submit a solution in a language of your choice.

i get run time error every

achitojha @ 25 Aug 2009 12:00 AM
i get run time error every time i submit i really can't figure out why my compiler isn't having any problem with the same code

Check out the FAQ for more

admin @ 25 Aug 2009 01:25 PM

Check out the FAQ for more information on run time errors.

#include main() {

rahul.mmec @ 25 Aug 2009 04:40 PM
#include main() { unsigned int wd; float fund; scanf("%d%f",&wd,&fund); if(wd%5!=0||(fund-wd)<0) printf("%.2f",fund); else { fund-=wd; fund-=0.5F; printf("%.2f",fund); } return 0; }

@Rahul, please remove your

leppyr64 @ 25 Aug 2009 07:50 PM
@Rahul, please remove your code. It will return WA. Test Case: 10 10.01

@Codechef Drupal Admin - I

leppyr64 @ 25 Aug 2009 07:51 PM
@Codechef Drupal Admin - I didn't realize you can't delete comments, please delete this one and my previous one please.

I am getting run time error

sumitb @ 28 Aug 2009 09:38 PM

I am getting run time error saying (NZEC) . I used help, its wriiten non zero exit code. My code is in java. Its running successfully in my system. class name is Main.  I have throws java.io.IOException also. Please help.

You probably have some issues

admin @ 28 Aug 2009 09:41 PM

You probably have some issues with the Input / Output.

Humen print kya karana

sumitb @ 30 Aug 2009 10:38 AM

Humen print kya karana hai:

Input:
30 120.00

Output:
89.50

 

yaa phir yeh karana hai:

30 120.00

89.50

 

Hello Admin plz reply soon

all the admins are frustating nobody helps

thinks they great coderss,all useless

class Main{ public static

sumitb @ 30 Aug 2009 10:58 AM

class Main{
public static void main (String[] args) throws java.lang.Exception{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
int x,flag=1;Double y;
x=Integer.parseInt(r.readLine());y=Double.parseDouble(r.readLine());
if(x%5==0 && (y-x)>=.5)y=y-x-.50;
System.out.println(y);
}}
 

 

Same code submitted by other user gets accepted

par mere mein RunTime Error(NZEC)

Admin where r u

Your code gives a runtime

triplem @ 30 Aug 2009 04:50 PM

Your code gives a runtime error on the sample input because the input is on one line. You don't need the admin when you can test your program by yourself.

@sumit You just have to print

admin @ 31 Aug 2009 01:43 PM

@sumit You just have to print 89.50 as the output.

i dont understand the meaning

dwatson_bynes @ 3 Sep 2009 05:06 PM

i dont understand the meaning of NZEC compiler error. Can you please guide me?

It is not a compile time

admin @ 3 Sep 2009 05:16 PM

It is not a compile time error. You can get a NZEC if your program returns with an status other than 0. You can check the FAQ at http://blog.codechef.com/2009/06/29/frequently-asked-questions/ for more information.

what problems do fall under

dwatson_bynes @ 3 Sep 2009 05:51 PM

what problems do fall under the category of OTHER in  runtime error?

What exactly do you mean ?

admin @ 3 Sep 2009 06:47 PM

What exactly do you mean ?

  #include<stdio.h> void

sindhuanki @ 4 Sep 2009 07:33 AM

 

#include<stdio.h>

void main(){

unsigned int w;
float total,b;
char ch='Y';

while(1)

{

printf("enter the amount u would withdraw(c that it is multiple of 5)n");

scanf("%d",&w);

 

printf("enter the balance");

scanf("%d",&b);

if(b>0 && b<2000)

{

if(b>w && w%5==0)

  total=b-w-0.50;

else

   printf("enter withdraw amt as multiple of 5 and <=balcancen");

}

else

 printf("enter the balnce <2000 n >0n");

printf("do u want to continue transcation Y/Nn");

scanf("%c",&ch);

if(ch=='N'|ch=='n')

{printf("thank you ");

break;

}

}

  #include<stdio.h> void

sindhuanki @ 4 Sep 2009 07:38 AM

 

#include<stdio.h>

void main(){

unsigned int w;
float total,b;
char ch='Y';

while(1)

{

printf("enter the amount u would withdraw(c that it is multiple of 5)n");

scanf("%d",&w);

 

printf("enter the balance");

scanf("%f",&b);

if(b>0 && b<2000)

{

if(b>w && w%5==0){

  total=b-w-0.50;

printf("current balnce:%f",total);

}

else

   printf("enter withdraw amt as multiple of 5 and <=balcancen");

}

else

 printf("enter the balnce <2000 n >0n");

printf("do u want to continue transcation Y/Nn");

scanf("%c",&ch);

if(ch=='N'|ch=='n')

{printf("thank you ");

break;

}

 

}

  #include<stdio.h> void

sindhuanki @ 4 Sep 2009 07:47 AM

 

#include<stdio.h>

void main(){

unsigned int w;
float total,b;
char ch='Y';

while(1)

{

printf("enter the amount u would withdraw(c that it is multiple of 5)n");

scanf("%d",&w);

 

printf("enter the balance");

scanf("%d",&b);

if(b>0 && b<2000 && b>w-0.50){

 if((int)w%5==0) 

   b=b-w-0.50;

else

   printf("enter withdraw amt as multiple of 5 and <=balcancen");

}

else

 printf("enter the balnce <2000 n >0n");

printf("current bal after transcation:%f",b);

printf("do u want to continue transcation Y/Nn");

scanf("%c",&ch);

if(ch=='N'|ch=='n')

{printf("thank you ");

break;

}

}

}

Do not post code here.

admin @ 4 Sep 2009 01:52 PM

Do not post code here.

What is wrong in this code?

vishnu.mnnit @ 9 Sep 2009 06:58 AM
What is wrong in this code? this robo compiler is not getting tht I have written correct code :( 

 

 

#include<stdio.h>

int main()

{

int withdraw= 0;

float total = 0;

  

   while(true)

   {

        scanf("%d %f",&withdraw,&total);

        if(withdraw>total || withdraw%5 )

        {

        printf("%.2f n", total);

        }        

        else 

        {

        printf("%.2f n", total - withdraw - 0.5);

        }

        }

   

    

return 0;   

}

 

 

It is not correct code. Your

triplem @ 9 Sep 2009 11:03 AM

It is not correct code. Your program never terminates.

Hi all,   I have tried to run

djain @ 16 Sep 2009 03:59 PM

Hi all,

 

I have tried to run the following code. But it is giving error on submiting the code. 

 

 

import java.io.BufferedReader;

import java.io.IOException;

public class Main {

public static void main(String[] args) throws IOException,

NumberFormatException {

BufferedReader r = new BufferedReader(new java.io.InputStreamReader(

System.in));

String[] s = r.readLine().split(" ");

double x=Double.parseDouble(s[0]);

double y=Double.parseDouble(s[1]);

if ((x>= y)|| (x%5 != 0)) {

System.out.println(y);

} else {

System.out.println(y- x - 0.50);

}

}

} 

 

 

Please help me in finding the point of error.

 

Thanks in advance,

 

#include <stdio.h> #include

krishnan_2009 @ 16 Sep 2009 09:16 PM

#include <stdio.h>
#include <conio.h>
void main()
{
int with;
float cur;
clrscr();
scanf("%d %f",with,cur);
if(!((with>=cur)||((with%5)!=0)))
cur=cur-with-0.5;
else;
printf("%f",cur);
getch();



}

what is wrong with this code...it shows compiler error..

can any one say how it happens???

@harikrishnan: firstly you

codebugger @ 19 Sep 2009 08:50 PM
@harikrishnan: firstly you need to format the output correctly:try using "%.2f" instead of "%f" secondly you got the if condition wrong ,it should be: if(!((with+0.5>=cur)||((with%5)!=0))) the initial balance should be withdrawal amount +0.5(for the current transaction) you should get it right....

cn any body tell me wt's prob

infotech @ 30 Sep 2009 05:23 PM

cn any body tell me wt's prob in this code

 

#include<stdio.h>
int main ()
{
float x,y;
scanf("%f %f",&x,&y);


if(x<y)
{
if(int(x)%5==0)
{printf("%.2f",((y-x)-.5));
}
else
{printf("%.2f",y);

}
}
else
printf("%.2f",y);

return 0;
}

My Java program runs with all

sheikhaman @ 2 Oct 2009 05:06 PM

My Java program runs with all given test cases and gives correct answers, but after submission, it says wrong answer!!??

the program is taking input from standard IO and is considering both the values to be written one after the other and seperated with a bank space.

 

the file is named as Main.java, still i get problems!!

Try these test

vsha041 @ 4 Oct 2009 05:40 AM

Try these test cases

INPUT

4.5 5
5 5.5
5 5
3.99 4.5
5.0 5.49
5.0 5.51

OUTPUT

5.00
0.00
5.00
4.50
5.49
0.01

#include<stdio.h> #include<c

snehasree @ 7 Oct 2009 06:51 AM

#include<stdio.h>

#include<conio.h>

void main(){

int w,B;

float R;

clrscr();

printf("enter the money for withdrawal");

scanf("%d",&w);

printf("enter the current balance");

scanf("%d",&B);

R=(float)B-w-0.5;

if(w%5==0&&w<B){

printf("%.1f",R);  }

else{

printf("%d",B);}

getch();

}

what's wrong in this solution it is showing compilation error

Read the FAQ.

triplem @ 7 Oct 2009 08:37 AM

Read the FAQ.

@VARUN SHARMA Thanks Varun

sheikhaman @ 8 Oct 2009 03:06 AM

@VARUN SHARMA

Thanks Varun bhai!!

i got where my code makes the flaw!!

Ok... with php, you cannot do

severeon @ 10 Oct 2009 06:40 AM

Ok... with php, you cannot do a number_format with this...

 

For some reason in php - output that has been formatted to have a precision of 2 is invalid...

#include<iostream>using

gowthaman @ 10 Oct 2009 10:47 AM

#include<iostream>
using namespace std;
void main(){
int a;
float b,c;
cin>>a;
cin>>b;
if(a%5==0)
if(a<b)
c=(b-a)-0.5;
else
c=b;
else
c=b;
cout<<c;
int i;
cin>>i;
}

#include<iostream>using

manoj.meda @ 12 Oct 2009 05:03 PM

#include<iostream>
using namespace std;
int main()
{
int amt;
double inamt;
cout<<"Enter the transaction amount"<<endl;
cin>>amt;
cout<<endl<<"Enter the initial balance";
cin>>inamt;
if(amt%5==0&&amt<=inamt)
{
float balance=inamt-amt-0.5;
cout<<endl<<balance;
}
else
cout<<inamt;
if(amt>=inamt||amt%5!=0)
cout<<inamt;
return 0;
}

impossible to do in C

kemalty @ 30 Oct 2009 01:26 AM

impossible to do in C

Thanks Varun .. I hope

rahularora @ 31 Oct 2009 08:39 PM

Thanks Varun .. I hope Codechef also tells us inputs where our program failed .. That will be highly appreciated.

hey Varun X can only be

shanky89 @ 12 Nov 2009 11:44 AM

hey Varun X can only be integer ... how r u taking both as float

its checking is wrong .. its

ashutoshsharma @ 15 Nov 2009 11:50 PM

its checking is wrong ..

its does not contain that 2000 boundation.

when i am making the program with this condition its reply with "wrong answer" but without this confition its accepted my answer.

i have tc2 compiler.how can i

snehasree @ 27 Nov 2009 06:49 AM

i have tc2 compiler.how can i install gnu compiler .i downloaded it but unable to do the next step.please help me out

Can anyone pls tell me wt's

ankit0311 @ 28 Nov 2009 12:25 PM
  1. Can anyone pls tell me wt's wrong with this code?
  2.  
  3. #include<stdio.h>
  4. main()
  5. {
  6. int x;
  7. float y,bal;
  8. scanf("%d %f",&x,&y);
  9. if(x>0 && x<=2000 && y>0 && y<=2000)
  10. {
  11.   if(x>y)
  12.   printf("%.2f",y);
  13.   else if(x%5!=0)
  14.   printf("%.2f",y);
  15.   else 
  16.   {
  17.    bal=y-x-0.50;
  18.    printf("%.2f",bal);
  19.   }
  20. }
  21. return 0;
  22. }   

 

Just try a variety of test

triplem @ 29 Nov 2009 04:07 PM

Just try a variety of test cases. One class of test case will show you what you've done wrong, and it shouldn't take you long coming up with it if you're methodical with your test cases.

package atm;import

sends2aaron @ 1 Dec 2009 11:24 AM

package atm;

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main
{
public static final double ATM_FEE = .5F;    //  50-cent ATM fee
public static final int MULT = 5;           //  Withdrawal multiple

public static void main(String[] args)
{
Scanner getInput = new Scanner(System.in);

DecimalFormat dollars = new DecimalFormat("#0.00");

double WithdrawalAmt = getInput.nextDouble();
double Balance = getInput.nextDouble();
double NewBalance = 0;
boolean LowBalance = (WithdrawalAmt >= Balance);
boolean NotMultiple = (WithdrawalAmt % MULT != 0);
boolean LessZero = WithdrawalAmt <= 0;

if(LowBalance || NotMultiple || LessZero)
{
System.out.println(dollars.format(Balance));
}
else
{
System.out.println(dollars.format(Balance - (WithdrawalAmt +
ATM_FEE)));
}
}
}

 

Keep getting "Wrong Answer" even though all of my test cases have passed muster.. I'm not quite sure what I'mt missing

By the way, when I submitted

sends2aaron @ 1 Dec 2009 11:26 AM

By the way, when I submitted the code (see above) I did erase "package atm;"

Your mistake is specifically

triplem @ 1 Dec 2009 11:38 AM

Your mistake is specifically pointed out in the second sentence of the problem statement.

Steve, "The cash machine will

sends2aaron @ 1 Dec 2009 07:54 PM

Steve,

"The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges)."

In my code, "NotMult" is there to determine if the remainder of (WithdrawalAmt / 5) is anything other than 0. If it is, then the amount that the user is requesting to withdraw is not a multiple of 5. This satisfied the first part of the second sentence.

The second part says "...enough cash to perform the withdrawal transaction (including bank charges)." I have set LowBalance equal to (WithdrawalAmt >= Balance):

Case 1: The user attempts to withdraw $120 when only $110 is available (greater than). "LowBalance" would catch this and cause the original balance to print out, as specified in the problem statement.

Case 2: The user attempts to withdraw $40 when his account balance is $40 (or equal to). Since $40.50 >= $40, "LowBalance" would catch this and cause the original balance to print out, as specified in the problem statement.

 

I have read, and reread both the second sentence of the problem statement, and my own code. I've also done more tests, and I don't see what it is that I'm missing.

Thanks for taking the time to glance over my code.

The only thing that I can

sends2aaron @ 1 Dec 2009 07:58 PM

The only thing that I can think of, Steve, is that perhaps LessZero should be < instead of <=. Because of this user is simply checking account balance, the withdrawal amount would be 0, but he or she would still be subject to the $0.50 ATM fee

Scratch that.. 0 < X <= 2000.

sends2aaron @ 1 Dec 2009 08:01 PM

Scratch that.. 0 < X <= 2000. Wish I could delete posts :)

is there anyway we can delete

ankit0311 @ 1 Dec 2009 08:36 PM

is there anyway we can delete the solutions that we have submitted? i submitted the same solution thrice by mistake...

@Stephen Thank you so much!

ankit0311 @ 1 Dec 2009 08:37 PM

@Stephen

Thank you so much! :)

 

@Stephen Thank you so much!

ankit0311 @ 1 Dec 2009 08:38 PM

@Stephen

Thank you so much! :)

 

wouldn't compile without a

lvfiveone @ 10 Dec 2009 10:44 PM

wouldn't compile without a return 0 in main... lame

My code is executing

siddharthdevilz @ 20 Dec 2009 06:50 PM

My code is executing perfectly on my system but i m getting runtime error from the judge. What is the error??

Are you returning 0 at the

admin @ 20 Dec 2009 06:51 PM

Are you returning 0 at the end of your program?

yes u can check my code.

siddharthdevilz @ 20 Dec 2009 07:02 PM

yes u can check my code.

Then there might be some

admin @ 20 Dec 2009 07:04 PM

Then there might be some problem with the way you are performing I/O

Working fine:: taking input

siddharthdevilz @ 20 Dec 2009 07:18 PM

Working fine:: taking input withdrawal amount as integer, balance as float and checking conditions and displaying balance. Also some working solns given on the site take withdrawal amount as float though it is specified in question that it is an integer.....?????

You have exit(1) in your

triplem @ 21 Dec 2009 02:21 AM

You have exit(1) in your code.. that specifically says to exit with an error.

Remember in Java to send

revelez @ 25 Dec 2009 03:50 PM

Remember in Java to send output as number not text.

#include<stdio.h>int

rumi2752 @ 26 Dec 2009 09:12 PM

#include<stdio.h>
int main(void)
{
int i;
float j;
scanf("%d %f",&i,&j);
if(i==0 || i>2000 || j>2000 || i>j || i%5!=0) printf("%.2f",j);
else printf("%.2f",j-i-0.5);

return 0;
}

i'm new here.......

can't  understand what is wrong with this code......

please inform me....

and also

please tell me how to perticipate in the compete

You are missing something in

triplem @ 27 Dec 2009 02:46 AM

You are missing something in the second sentence of the problem statement.

what the heck is going on

Dudio @ 27 Dec 2009 10:05 AM

what the heck is going on dude? It keeps testing wrong...this program is written perfectly. All test cases I could think of... WHAT THE!!

It is wrong. For the same

triplem @ 27 Dec 2009 10:38 AM

It is wrong. For the same reason as mentioned above; the case you are missing is specifically mentioned in the problem statement.

ahhh this is ridiculous 

Dudio @ 27 Dec 2009 12:36 PM

ahhh this is ridiculous  ;o

 

I don't see what's wrong with my code anymore...I'm doing to bed now.  LoL

@stephen thank u . got

rumi2752 @ 27 Dec 2009 12:39 PM

@stephen

thank u .

got accepted

please tell me how to

rumi2752 @ 28 Dec 2009 02:13 PM

please tell me how to perticipate in the january algo challenge....

is it possible without forming a team?

if not , how can one form a team????

please admin  or   aniruddha   or   stephen.....

answer me..

hello sir i have succesfuuly

rajesh bhatia @ 1 Jan 2010 12:46 PM

hello sir i have succesfuuly run this program in turbo c.but here it is shown wrong answer.

here is my program:

#include<stdio.h>
int main()
{
 float y,z;
 int x;
 printf("input:");
 scanf("%d %f",&x,&y);
 if(((float)x)>y)
 {
   printf("%.2f",y);
 }
 else if(x%5==0)
 {
   z=(y-x)-0.50;
   printf("%.2f",z);
 }
 else
 {
   printf("%.2f",y);
 }

 return 0;
}

so cn u give me ans why it is worng.

my email_id is:rajesh91bhatia@gmail.com

do not use dat " 

sreejith @ 1 Jan 2010 01:26 PM

do not use dat "  printf("input:"); "

if u will read d faq its wriiten over der u only need to take d i/p n giv its o/p nothin xtra.

 

n u better check dis i/p "120 120.00"

Can someone point error in

xtream @ 7 Jan 2010 11:48 PM

Can someone point error in below program

 

import java.text.NumberFormat;

public class Main
{
 public static void main (String[] args) throws java.lang.Exception
 {
 java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
 String input [] =r.readLine().split("\s+");
 double withdrawAmount = Double.parseDouble(input[0]);
 Double totalAmount = Double.parseDouble(input[1]);
 if(withdrawAmount%5==0&&(withdrawAmount+0.5)<=totalAmount)
 {
  double  balance = totalAmount-(withdrawAmount+0.5);
  System.out.println(roundTwoDecimals(balance));
  
 }
 else
 {
  System.out.println(roundTwoDecimals(totalAmount));
 }
 
}
 
static String roundTwoDecimals(double d)
{
     NumberFormat fmt  =NumberFormat.getInstance();
     fmt.setMaximumFractionDigits(2);
     fmt.setMinimumFractionDigits(2);
     return fmt.format(d);
 
}
}

#include<stdio.h> void

sandipa @ 9 Jan 2010 04:45 PM

#include<stdio.h>

void main()

{

int x;

float b;

printf("Enter withdrawal amt and bal");

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

if(x%5==0 && x<=2000 && x>0 && x<b && b<=2000 && b>0)

{

printf("%.2f",(b-x)-0.5);

}

else

{

if(b>2000)

{

printf("balance cannot be greater than 2000");

getch();

exit(0);

}

printf("%.2f",b);

}

getch();

}

@sandipa read FAQ

Geniusguy @ 9 Jan 2010 05:37 PM

@sandipa read FAQ

your code has many errors

Geniusguy @ 9 Jan 2010 05:40 PM

your code has many errors like you cannot use getch(). . .main must return an integral value. . . .

moreover you need not to print text like enter money etc etc. . .as your program is judged by a computer judge . . .So please go through http://www.codechef.com/freelinking/FAQ once ! ! !

/usr/local/bin/java compile:

ArchanaM @ 12 Jan 2010 07:04 PM

/usr/local/bin/java compile: line 3: 28306 Aborted /usr/local/jdk/bin/javac -d /tmp /sources/Main.java 1>&-

 

what does this error mean?

//ATM import

ArchanaM @ 13 Jan 2010 03:38 PM

//ATM

import java.lang.*;
import java.io.*;

class operations
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
double y;
double x;
double z;
double charge;

 

 public void input()throws IOException,NumberFormatException
 {

//AMOUNT TO BE WITHDRAWN
System.out.println("Enter amount of money to be withdrawn");
try
{

x=Double.parseDouble(br.readLine());
}

catch (Exception e)
{
System.out.println("Enter double value");
}


if((x%5!=0))
 {
System.out.println("Enter multiple of 5");

 }
else if((x<=0)||(x>2000))
 {

System.out.println("Enter proper value");
System.exit(0);
 }
//code for entering balance
System.out.println("Enter your balance");
try
{

y=Double.parseDouble(br.readLine());
}

catch (Exception e)
{
System.out.println("Enter double value");
}

 

if((y<=0))
  {
 System.out.println("Enter positive balance");
 System.exit(0);
  }

else if ((y>=2000))
{
  System.out.println("Balance should not exceed 2000");
  System.exit(0);
}

}  

 
 public double withdraw()
 {
z=y-x;
charge=z-0.50;
if((x>=y)||(x%5!=0)||(charge<0))
  {
 System.out.printf("%.2f%n",y);
  }
else
  {
 System.out.printf("%.2f%n",charge);
  }
return z;
 }

}
class ATM
{
 public static void main(String[] args) throws IOException,Exception
 {
System.out.println("Hello,Welcome to Priya's Account!");
operations o=new operations();
o.input();
o.withdraw();

 }
}

i dont know why it is giving compilation error...it is checking all test cases

Read the FAQ. You must have a

triplem @ 13 Jan 2010 03:41 PM

Read the FAQ. You must have a public class called Main.

I submitted the solution in c

anil1in7 @ 15 Jan 2010 04:18 PM

I submitted the solution in c and used .2f and .02f for precision, how come both of the solutions got accepted?

// ATM transactions#include

anzy.neatfreak @ 17 Jan 2010 07:30 PM

// ATM transactions
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int withdraw_amount;
double balance;
cin >> withdraw_amount >> balance;
cout << setprecision(2) << fixed;

if(withdraw_amount % 5 != 0 || withdraw_amount > balance)
{
cout << balance << endl;
}
else
{
balance = balance - withdraw_amount - 0.5;
cout << balance << endl;
return 0;
}
}

What's wrong with this one can anyone please explain to me? I'm getting a runtime error.

Very new to this site.. Can

yuvraj @ 21 Jan 2010 08:32 PM

Very new to this site..

Can someone please let me know if my submission format is correct?

-----------------------------------------------------------------------

#!/usr/bin/perl

$withdraw=$ARGV[0];

$balance=$ARGV[1];

 

if($withdraw < $balance){

$check_case = ($withdraw%5);

 

if(!$check_case){

$remain_balance = $balance - ($withdraw + 0.5);

print $remain_balance;

}

else{

print $balance;

}

}

else{

print $balance;

}

How about this..!   It works

yuvraj @ 21 Jan 2010 08:43 PM

How about this..!

 

It works perfect for me when I run from command line...!

-----------------------------------------------------------

#!/usr/bin/php

<?

$user_withdrawl = $argv[1];

$account_balance = $argv[2];

 

$new_balance = 0;

 

if($user_withdrawl < $account_balance){

if(!($user_withdrawl%5)){

$new_balance = $account_balance - $user_withdrawl - 0.5;

}

else{

$new_balance = $account_balance;

}

 

}

else{

$new_balance = $account_balance;

}

echo sprintf("%.2f", $new_balance);

 

?>

Can anyone of you please look

yuvraj @ 21 Jan 2010 09:31 PM

Can anyone of you please look into my php code and let me know what format I need to publish the code in.

http://www.codechef.com/viewsolution/171195

 

Please get back to me so I can actively participate on furthermore competition.

#include<iostream>#include<io

kunalshridhar @ 22 Jan 2010 01:10 AM

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
unsigned int X;
float Y;

cin>>X>>Y;

if(X>=Y || X%5!=0)
cout<<fixed<<setprecision(2)<<Y;
else
cout<<fixed<<setprecision(2)<<float (Y-(X+0.50));

system("pause");
return 0;
}

This code is rejected. Can anyone tell what's the problem with it?

@yuvrav and Kunal - both of

triplem @ 22 Jan 2010 02:12 AM

@yuvrav and Kunal - both of you read the FAQ.

I dont know how i m getting

harshit.tiwari @ 27 Jan 2010 01:46 PM

I dont know how i m getting wrong answer. some one help or else authorities must look in to it

#include<stdio.h>

int main()
{
float bal;int wid;
scanf("%d",&wid);
scanf("%f",&bal);
if(wid>bal)
;
else if(wid%5==0)
bal=bal-wid-0.5;
printf("%0.2f",bal);
return 0;
}

Read the FAQ. And also the

triplem @ 27 Jan 2010 02:01 PM

Read the FAQ. And also the problem statement, as you are ignoring part of it.

What the fuck? hey dude! its

surajtomar @ 2 Feb 2010 12:44 PM

What the fuck?

hey dude! its working correctly on my environment.....

hey will you plz tell me how

surajtomar @ 2 Feb 2010 12:46 PM

hey will you plz tell me how itz getting tht eror

#include<stdio.h>int main(){

mic.ceo @ 7 Feb 2010 11:27 AM

#include<stdio.h>
int main()
{
int amt;
float bal;
scanf("%d %f",&amt,&bal);
if((amt>0) && (amt<=2000) && (amt%5==0) && (amt<(bal+0.50)) && (bal>0) && (bal<=2000))
{
bal=bal-amt-0.50;
}
printf("%.2f",bal);
return 0;
}

this code is working correctly for all example cases in my machine on dev c++ as well on gcc compiler on ubuntu

can sm1 plz tell me wat changes to do to make this solution as accepted""

FAQ

triplem @ 7 Feb 2010 01:21 PM

FAQ

i have written the code using

shubh09 @ 12 Feb 2010 11:26 PM

i have written the code using java. its working fine on my computer. but its giving a runtime error on submission.

If you're getting a runtime

triplem @ 13 Feb 2010 02:07 AM

If you're getting a runtime error then you have made a mistake, so it won't be working fine on your computer.

i am getting wrong answer but

abhisheksoni @ 20 Feb 2010 06:20 AM

i am getting wrong answer but i dont know y??

can any one help me plz.

#include<stdio.h>
int main()
{

int x1;

float x;

scanf("%d %f",&x1,&x);
if(x1 > x)
{ printf("%.2f",x);}
else if(x1 % 5 ==0) {
if(x1 < x)
printf("%.2f",((x-x1)-0.50));   
else
printf("%.2f",x); }
else
{ printf("%.2f",x);}
return 0;
}

What you are doing wrong is

triplem @ 20 Feb 2010 10:45 AM

What you are doing wrong is clearly specified in the problem statement - read it again. And please don't post code - see the FAQ.

Getting a Runtime Error NZEC

arpitpanwar @ 5 Mar 2010 03:56 PM

Getting a Runtime Error NZEC everytime...ive re run the Code several times with the given Input...and everytime i get the correct output ...but when i submit it i get a rumtime error

As you've already realised,

triplem @ 5 Mar 2010 04:31 PM

As you've already realised, it was obvious why it was giving a runtime error. You weren't testing your code properly; the input appears on one line and your program couldn't cope with that.

It's now getting a wrong answer because you haven't handled the various cases properly. There aren't many to test so it should be easy to find the one it fails on.

The Code is working perfectly

arpitpanwar @ 5 Mar 2010 04:44 PM

The Code is working perfectly on ALL the 3 Conditions...dont know why is it giving me Wrong Answer....i have tested the code with all the Possible Conditions

No you haven't, The problem

triplem @ 6 Mar 2010 01:48 AM

No you haven't, The problem statement even specifically mentions something that you are doing wrongly. If you can't find the bug then you haven't read the problem statement.

#include<stdio.h>main(){float

Aveekc @ 6 Mar 2010 10:03 PM

#include<stdio.h>
main()
{
float b,c=0.00;
int a;
scanf("%d %f",&a,&b);
if((a%5)!=0||b-a<.50)
{
printf("n%.2f",b);
}
else
{
c=b-a-.50;
printf("n%.2f",c);
}
return 0;
}

 

HEEEELP MAN!WORKS FYN ON MA MACHINE!WRONG ANSWER?DARN!

When I go through all the

cranil @ 7 Mar 2010 05:07 PM

When I go through all the comments I realize not many people have patience :)... Feynman was sooo right :) [duh!]

while submitting if i choose

linuxfreak @ 10 Mar 2010 12:06 AM

while submitting if i choose ... c++ as language.. then a message pops.. that i can't submit in this language... try the link!! wht's this... i can see.. other people. submitting in c++ !!

@Stephen, do you think that a

enrique3 @ 12 Mar 2010 02:45 AM

@Stephen, do you think that a Bank will let you do any transaction you want without knowing that you have enough money to pay up for it? -_- hehe

@Nitin Kumar, I got this

Pangsit @ 12 Mar 2010 07:28 AM

@Nitin Kumar, I got this problem too when I choose C++ (g++ 4.3.2). I managed to submit it by choosing C++ (g++ 4.0.0-8). Hope this helps!

@pangsit .. thanx!! i too

linuxfreak @ 12 Mar 2010 07:57 AM

@pangsit .. thanx!! i too submitted it in g++ 4.0.0-8 and it worked for me..

It is working fine, but not

aberry @ 17 Mar 2010 10:56 AM

It is working fine, but not sure it is always throwing runTime error everytime

this is python code

 

wmoney = int(raw_input())
tmoney = float(raw_input())
if (wmoney%5)==0 and ((tmoney - 0.50) >= wmoney):
bal = tmoney - wmoney - 0.50
else:
bal = tmoney

print '%.2f'%bal

 

 

is it need input by separated space ...

any clue

The sample input is pretty

triplem @ 17 Mar 2010 11:21 AM

The sample input is pretty clear.

using System;using

zaira @ 3 Apr 2010 10:33 AM

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
             
                int a, b;
                Console.WriteLine("enter the amount for withdrawl?");
                a = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter the balance? ");
                b = Convert.ToInt32(Console.ReadLine());
            if( (a>0 && a<2000) && (b>0 && b<2000) )
            {
              

                if (a % 5 == 0 && a<b )
                {

                    Console.WriteLine(String.Format("{0:0.00}", b - a - 0.5));
                    Console.WriteLine("successfull withdawl");
         
                }
                else if (a > b)
                {
                    Console.WriteLine("Insufficient balance");
                    Console.WriteLine("balancee is" + b);


                }
                else
                {
                    Console.WriteLine("not a multiple of 5");
                    Console.WriteLine(b);
 
                }
            }
            else

                Console.WriteLine("amount is greater than 2000! limit exceed!");
                Console.ReadLine();
        
        }
        }
    }

 

c# code

Giving Right result... check it further....

Read the FAQ.

triplem @ 3 Apr 2010 12:11 PM

Read the FAQ.

#include <iostream>#include

PARAG JAIN @ 15 Apr 2010 10:26 PM

#include <iostream>
#include <conio>

void main()
{
int x,y;
cin>>x>>y;
if(x%5==0)
{
if(y<=(x+0.5))
cout<<x;
else
cout<<y-(x+0.5);
}
getch();
return 0;
}

 

whats wrong in this code ,it is showing compile time error.............

FAQ

triplem @ 16 Apr 2010 04:32 AM

FAQ

iin any wrong case (like if

kkneeraj @ 19 May 2010 09:46 PM

iin any wrong case (like if one inputs outside the limits )we have to print the balance

suppose the balance is outside limits  then also we have to print balance only.

If the problem says a number

triplem @ 20 May 2010 03:00 AM

If the problem says a number will lie between two bounds then it will.

frns i can't upload any

jeevan4 @ 20 May 2010 06:36 PM

frns i can't upload any solutin here ..!! it says wrong password or login ..... why i am getting this error ?? plz help me to upload a solution ....frns plz plz plz :)

hi i tried to run ATM code

samirvasani @ 1 Jun 2010 03:26 PM

hi i tried to run ATM code using codechef compiler it shaws me a compiler error while the same programm runs successfully on my TURBO C compiler .i dont know why is this happens

 

pls read the code below and tell me if there is any erro or any of the conditions that is given in the question is not satisfied

 

#include<stdio.h>
#include<conio.h>

void main()
{
int ibalance,iamount;
float ioutput;
clrscr();

printf("enter the amount to be withdrawn and initial balancen");
scanf("%d %d" ,&iamount,&ibalance);

if(iamount<ibalance  && iamount%5==0 )
{
ioutput=ibalance-iamount-0.50;

printf("your current balance is %f n",ioutput);

}

else if(iamount>ibalance)
{
printf("enter amount below the balance");
}

else if(!(iamount%5==0))
{
printf("enter the amount multiple of 5");
}

getch(); 
}



FAQ

triplem @ 1 Jun 2010 03:29 PM

FAQ

(code removed)

linus1221 @ 8 Jun 2010 04:35 PM

(code removed)

Please do not post code. Read

triplem @ 8 Jun 2010 04:43 PM

Please do not post code. Read the FAQ.

if pooja enters a withdrawl

periaganesh @ 25 Jun 2010 12:01 PM

if pooja enters a withdrawl amount of '$0',do we need to deduct  $0.50 from her account balance.

#include<stdio.h> int

saranya_sivanandham @ 12 Jul 2010 11:24 PM

#include<stdio.h>

int main()

{

float bal=0.0,check;

int withdraw;

scanf("%f %d",&bal,&withdraw);

if((withdraw+0.50)<=bal && withdraw%5==0 &&bal<=2000)

bal-=(withdraw+.50);

printf("%.2f",bal);

return 0;

}

This is my code and it works very well in turbo C.. but it is mentioned as wrong answer.. Wy it is so??

Can anyone help me????

 

You're mixing up which

triplem @ 13 Jul 2010 03:04 AM

You're mixing up which numbers in the input are integers and which aren't.

I tried pasting the code, but

a_singh @ 27 Jul 2010 05:54 PM

I tried pasting the code, but I got this message : "You can't submit in this language for this problem. Try link." I got the same thing while uploading the code.

HI ,CAN ANYBODY PLEASE TELL

Innovator_C @ 4 Aug 2010 01:59 AM

HI ,CAN ANYBODY PLEASE TELL ME WHAT IS WRONG WITH MY CODE

http://www.codechef.com/viewsolution/297947

PLEASE HELP!!

@Ayush-You are not printing

anish7766 @ 4 Aug 2010 08:09 AM

@Ayush-You are not printing the result only....

@Anish- Thanks

Innovator_C @ 4 Aug 2010 02:56 PM

@Anish- Thanks

i cannot post my code. it

mbchandar @ 13 Aug 2010 08:43 PM

i cannot post my code. it says wrong login or password... :(

Hi,   I am getting Runtime

balajikandan @ 19 Aug 2010 02:47 AM

Hi,

 

I am getting Runtime error when i submit my solution for the problem. Pls share me why it comes and what might be the reason behind it.

Note: pls dont point to FAQ

 

Thanks,

BalajiKandan

Thanks, i have fixed it....

balajikandan @ 19 Aug 2010 02:52 AM

Thanks, i have fixed it.... :)

time limit exceeded wtf!!!

coolsainideepak @ 21 Aug 2010 12:08 PM

time limit exceeded wtf!!!

#include<stdio.h> main() { f

Ashwini Hegde @ 22 Aug 2010 11:05 AM

#include<stdio.h>

main()

{

float b;

int w;

scanf("%f%d",&b,&w);

if(w%5==0)

{

if(w<b-.5)

printf("%.2f",b-w-.5);

else

printf("%.2f",b);

}

else

printf("%.2f",b);

}

can i please please know wats wrong with this code....this is happenin lik innumerable times!!!!!!!!

#include<stdio.h>main(){float

mukes01 @ 25 Aug 2010 11:14 AM

#include<stdio.h>
main()
{
float t_a;
int w_d;
printf("Enter the amonut and  available balnace");
scanf("%d%f",&w_d,&t_a);
if (w_d % 5==0 && w_d< = t_a - 0.5 )
{  printf("outputn");
printf("%f",t_a-w_d-0.5);
}
else if
(w_d % 5 !=0 || w_d < t_a-0.5 )
printf("%f",t_a);
}

#include <iostream> using

jayammahesh @ 9 Sep 2010 05:59 PM
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void try_withdrawal(int & amount, float & balance)
  6. {
  7. if(((amount + 0.5) <= balance)
  8. && ((amount % 5) == 0))
  9. {
  10. balance = balance - amount - 0.5;
  11. }
  12. }
  13. int main()
  14. {
  15. int amount;
  16. float balance;
  17. cin >> amount >> balance;
  18. try_withdrawal(amount, balance);
  19. cout.precision(2);
  20. cout << fixed << balance << endl;
  21. return 0;
  22. }

not bad for starting.

akbarjon @ 10 Sep 2010 04:49 PM

not bad for starting.

i am unable to submit

gestapo @ 11 Sep 2010 08:12 AM

i am unable to submit solutions at this moment??what is the problem?

#include<stdio.h>void

bharatv @ 14 Sep 2010 02:30 PM

#include<stdio.h>
void main()
{
float balance;
int amount;
scanf("%d%f",&amount,&balance);
if((amount%5)==0&&(amount<balance))
printf("%.2f",balance-amount-0.50);
else
printf("%.2f",balance);
}

#include<stdio.h> int

ben_hilfy @ 16 Sep 2010 08:06 AM

#include<stdio.h>

int main()

{

float prev_balance;

int withdrawal;

scanf("%d%f",&withdrawal,&prev_balance);

if((withdrawal<prev_balance) && ((withdrawal%5)==0))

prev_balance=prev_balance-withdrawal-0.50;

printf("%.2f",prev_balance);

getch();

return 0;

}

plaese tell me why codechef

ben_hilfy @ 16 Sep 2010 08:07 AM

plaese tell me why codechef is giving response as wrong answer

It is possible for your

triplem @ 16 Sep 2010 09:44 AM

It is possible for your program to output a negative balance.

My first successful

saik @ 20 Sep 2010 12:49 AM

My first successful submission. Good one to start with.

What is wrong with this

hasitpbhatt @ 21 Sep 2010 10:56 PM
What is wrong with this code??????????????????????? Telling Compile Time Error............. Though it works best on my c compiler........ //Header files #include #include //Starting Of Program void main() { //Declaration int amt; float bal; clrscr(); //To clear the screen start: printf("Enter the amount of cash you want to withdraw:"); scanf("%d",&amt); //Condition for positive integer if (amt <= 0) goto start; start1: printf("Enter the account balance:"); scanf("%f",&bal); //condition for non-negetive float number if (bal < 0) goto start1; if (bal >= amt) { if (amt % 5 == 0) printf("Successful Transactionn %.2f",bal-(float)amt-0.50); else printf("Incorrect Withdrawal Amountn%.2f",bal); } else { printf("Insufficient Funds"); printf("%.2f",bal); } end: getch(); }

what is wrong with this it is

riymaria @ 23 Sep 2010 12:34 PM
what is wrong with this it is python its showing runtime error???????????????????????? Amount=raw_input("Enter Amount:") Amount1=raw_input("Enter Amount:") withdraw=int(Amount) Ac_balance=int(Amount1) if withdraw%5 == 0 and withdraw < Ac_balance: new_balance=Ac_balance - withdraw new_balance = new_balance-.5 print'%.2fn' % (new_balance) elif withdraw%5 != 0 or withdraw > Ac_balance: print '%.2fn' % (Ac_balance)

#include<iostream>#include<m

charchit @ 24 Sep 2010 02:32 PM

#include<iostream>
#include<math.h>
using namespace std;
main()
{
int c;
float d=0,u=0,Y,X,x;
cin>>X>>Y;
x=floor(X)+.50;
c=X;
if (X-floor(X)==0 && c%5==0 && Y>=x)
{Y=Y*100;x=x*100;
Y=Y-x;
Y=Y/100;}
u=Y-floor(Y);
Y=floor(Y);
cout<<Y<<".";

d=floor(u*10);
cout<<d;
d=u*100-d*10;
cout<<floor(d);

return 0;
}

To: any one who knows....
this was the program I wrote n cant understand that y the out put is 5.48 when i give input> 5  5.49 :(
here Y=5.49 and since it is < 5 + 0.5 the output should b 5.49
if any one can help plzzzzzz tell

mischief managed :Dplz ignore

charchit @ 24 Sep 2010 02:39 PM
mischief managed :D
plz ignore the above comment

Few points to be kept in

wishy @ 2 Oct 2010 05:26 PM

Few points to be kept in mind:

1. only the withdrawal amount has to be a multiple of 5

2. the withdrawal amount to be an INT

3. Don't display unnecessary "cout"s. The solution will not get accepted even if it running perfectly on your compiler.

4. The output will be the balance entered itself, unless the amount is an integer multiple of 5 and is <bal-.5

 

Happy Coding

i m getting error ... " you

coolmegadeth @ 2 Oct 2010 08:08 PM

i m getting error ... " you cant submit in this language for this problem " ..while i m submitting it in c language !! wat is the problem.. !! somebody help !! i have submitted the following

 

#include<iostream>

 

using namespace std;

 

int main()

{

double x;

int y;

char ch='y';

cout<<"cash at ur accountn";

cin>>x;

while (ch=='y')

{

 

cout<<"amount u want to withdrawn";

cin>>y;

if (y>x)

cout<<"insufficent fundsn";

else

{ if(y%5==0)

x=((x-y)-0.5);

 

cout<<"new account balance = n"<<x;

cout<<"do u want to withdraw more y/n";

cin>>ch;

}

}

return 0;

}

Not able to submit my

zingoba @ 6 Oct 2010 04:13 PM

Not able to submit my solution. Prompt says :

"You cannot submit in this language for this problem. Try link."

What does it mean? My solution uses C++ 4.3.2 .

any body .plz tell why this

navicpp @ 9 Oct 2010 06:22 PM

any body .plz tell why this is a wrong answer.....

#include <iostream>
using namespace std;

int main()
{
float a,bal;
cin>>a>>bal;
if(((int)a % 5)==0&& (a+0.50)<=bal)
{
bal= bal-(a+0.50);
cout.precision(4);
cout<<bal;
}
else
{
cout.precision(4);
cout<<bal;
}
return 0;
}

plzzzzzzzzzzzz.................

Dead Thread!

zingoba @ 10 Oct 2010 06:34 PM

Dead Thread!

im uplaoding my  code

garfieldm89 @ 20 Oct 2010 12:17 AM

im uplaoding my  code programmed in dev C++ 4.9.9.2 supporting GCC

here is my code...its running perfectly in software

when im uplaoding here, its saying cant uplaod in the selected language..my language is C++ ( gcc 4.3.2)

 

#include<iostream>
using namespace std;
int main()
{
int draw;
float bal;
cin>>draw;
cin>>bal;
if (draw % 5==0)
{
if (draw < bal-0.50)
bal=bal-float(draw)-0.50;
cout.precision(2);
cout<<bal;
}
else{ cout.precision(2);
cout<<bal;}


return 1;
}

I'm submiting this code in

funducm @ 22 Oct 2010 07:13 PM

I'm submiting this code in C:

#include <stdio.h>
int main() {
float balance=0.0, money=0.0;
scanf("%f", &money);
scanf("%f", &balance);
(money >= balance || ((int)money%5 != 0)) ? printf("%.2fn", balance) : printf("%.2fn", balance-money-0.50);
return 0;
}

This works perfectly fine in my machine. But here I'm getting messages like: "wrong answer and sorry internal error"

Can anyone help me in this? I hope, I'm printing what question has asked :P

Ignore the internal errors;

triplem @ 23 Oct 2010 02:23 AM

Ignore the internal errors; they have been happening regularly recently and you can still see the result of your submission via the My Submissions page.

The wrong answer is because you are not printing what the question has asked. Read the second sentence of the problem statement; you aren't doing what it says.

I m a C# user, how can i read

jravi96 @ 1 Nov 2010 07:27 PM

I m a C# user, how can i read two integers from a single line, how z that possible?

plz put on some light

@ravi Here is my C# Accepted

youzelin @ 4 Nov 2010 11:09 AM

@ravi

Here is my C# Accepted Code, FYI:


using System;
using System.Collections.Generic;
using System.Text;

namespace CodeChef
{
    class Program
    {
        static void Main(string[] args)
        {
            for (string input = Console.ReadLine(); !string.IsNullOrEmpty(input); input = Console.ReadLine())
            {
                string[] parameters = input.Split(' ');

                // Parse parameters
                int withdraw = int.Parse(parameters[0]);
                double balance = double.Parse(parameters[1]);

                // Output
                if (withdraw % 5 == 0 && balance - withdraw >= 0.5)
                {
                    Console.WriteLine("{0:F2}", balance - withdraw - 0.5);
                }
                else
                {
                    Console.WriteLine("{0:F2}", balance);
                }
            }
        }
    }
}


For some reason(s), the

tomchie @ 4 Nov 2010 12:19 PM

For some reason(s), the website shows compiling error for .java files; while the same files compile, run and give correct outputs for all the test cases that I have tested..

I guess, the better idea is to practice the problems provided on the website and check the results yourself instead of wasting time on submitting and reformatting the running code. But then it is not always possible to think of all the possible test cases to check your code's precision.

Another interesting observation is that most of the successful submissions here are in C/C++.. I have rarely seen any "successful" submission of .java file.. Probably the website needs to provide more specific guidelines on how to format/submit the .java files specifically for codeChef compiler.

However, nice source to practice and learn..

Thank you Directi...

Did you notice right below

triplem @ 4 Nov 2010 01:56 PM

Did you notice right below the 'Post new comment' heading was 'Have you browsed through the FAQ'? Which happens to explain exactly what the problem is with your code? ;)

I guess there is some problem

nicepeeyush @ 5 Nov 2010 04:12 AM

I guess there is some problem with system. I uploaded my code 6 times(which was working fine on my system) and it showed wrong answer. Then i copied one of the given and accepted solution, changed the variable names, uploaded it again and strange its wrong answer again. Admin, could you please explain whats the problem here?

phew....finally done with

nicepeeyush @ 5 Nov 2010 04:29 AM

phew....finally done with it.....!!

There is no problem with the

triplem @ 5 Nov 2010 04:31 AM

There is no problem with the system. Your own code is repeatedly getting wrong answer because all of them do indeed give the wrong answer. Which of the submissions (copy the link from the My Submissions page so I can see it) was the one where you copied an accepted solution? I suspect you did more than just change variable names.

@stephen: I got it right. I

nicepeeyush @ 6 Nov 2010 02:38 AM

@stephen: I got it right. I dont know where my code my was wrong but i do know that i made some stupid change in my previous code and it got accepted, i am working on that. Anyways thanks for your reply.

giving wrong solution/// bt

cooladi8 @ 17 Nov 2010 12:36 AM

giving wrong solution///

bt in my dev compiler its giving right solution..

I'm getting a "Runtime Error"

generatorx @ 18 Nov 2010 10:27 PM

I'm getting a "Runtime Error" when submitting this program. One of the FAQ's says that "I might be using too much memory" for this particular program...but I don't agree *if that is even the case*. And if that *is* the case? I'm not going to "golf" this program down, it's good enough for a beginners program.

 

I think the Runtime Error is on http://www.codechef.com end. :p

That's only one reason the

triplem @ 19 Nov 2010 02:31 AM

That's only one reason the FAQ says you may be getting a runtime error.

Your code will get a runtime error on absolutely every single test case, including the sample input. You should try testing your code properly first ;) (Your code assumes the two numbers will be on different lines, when this is of course not the case).

http://www.codechef.com/views

sivach @ 19 Nov 2010 03:31 PM

http://www.codechef.com/viewsolution/381520

can anyone check this pls... its mention as runtime error. but in my system it worked successfully.

Your code fails in exactly

triplem @ 20 Nov 2010 01:13 AM

Your code fails in exactly the same way as I mentioned in the comment directly above yours.

My program works exactly

rashizzle @ 5 Dec 2010 11:08 AM

My program works exactly (tested your input), but when I submit it says 'Wrong Answer'.

I ran my program exactly how

rashizzle @ 5 Dec 2010 11:18 AM

I ran my program exactly how the FAQ said to.

That is because your code is

triplem @ 5 Dec 2010 12:07 PM

That is because your code is wrong. Read the problem statement carefully; you are missing one instruction.

Hey checking for the boundary

avi007i @ 11 Dec 2010 09:18 AM

Hey checking for the boundary conditions and the other conditions too. sayin "Wrong answer".

 

 

#include<stdio.h>

int main()
{
int a;
float b;
scanf("%d %f",&a,&b);


if( a<=0 || a>2000 || b<0 || b>2000)
return 0;

else if((a>b)  || (a%5!=0))
printf("%.2fn",b);

else
{
b= b-a -0.5;
printf("%.2fn",b);
}
return 0;
}

That's because you haven't

triplem @ 11 Dec 2010 09:36 AM

That's because you haven't tested the 'other conditions' properly like you say you have. As per my comment above, read the problem statement carefully.

thanx stephen !! got it !!

avi007i @ 11 Dec 2010 11:53 AM

thanx stephen !!

got it !!

i used unsigned short int for

s3thu @ 12 Dec 2010 12:01 AM

i used unsigned short int for X but its showin run time error. It works fine wit int. Cant i use usi for savin mem space in this program?

You can use it, but %u is not

triplem @ 12 Dec 2010 01:09 AM

You can use it, but %u is not how you read an unsigned short with scanf.

this code is working finely

sabyasachi3 @ 14 Dec 2010 09:29 PM

this code is working finely in my machine , but why it is giving a runtime error? Can anyone help???

 

 

#include<stdio.h>

main()

{
float acc_bal, with_bal, prev_bal ;
int w_b, flag = 0 ;

printf("nENTER ACCOUNT BALANCE:t");
scanf("%f", &acc_bal );
printf("nENTER WITHDRAWAL BALANCE:t");
scanf("%f", &with_bal );

w_b = with_bal ;
prev_bal = acc_bal ;

if( w_b % 5 != 0 )
;

else if( with_bal > acc_bal)
printf("nINSUFFICIENT BALANCE!!! ");

else
{

acc_bal = acc_bal -  with_bal - 0.50 ;
flag = 1;


}


if( flag == 1 )
{
printf("n***TRANSACTION SUCCESSFUL*** ");
printf("nUPDATED ACCOUNT BALANCE : %0.2fnWITHDRAWN : %.2fn ", acc_bal, with_bal);
}

else
printf("n ACCOUNT BALANCE : %0.2fnWITHDRAWN NOT DONEn" , prev_bal );

Read the FAQ.

triplem @ 15 Dec 2010 01:31 AM

Read the FAQ.

my code is running fine for

bhushansc007 @ 15 Dec 2010 07:31 AM

my code is running fine for all cases on linux and here its giving me the "Runtime error". can anyone explain?

thanks!

Yes. In fact, I already did,

triplem @ 15 Dec 2010 07:47 AM

Yes. In fact, I already did, a long time ago, in the FAQ.

can u point out the problem

akshitpoddar @ 17 Dec 2010 02:38 PM

can u point out the problem in my last submission?...it shows wrong ans...*HELP*

//it is showin wrong

iresh @ 18 Dec 2010 12:12 PM

//it is showin wrong ans....but i dont know why??..plz help

 

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int a;
float b;
cin>>a>>b;
if(b>a)
{ if(a%5==0)
   b=b-a-0.5;
 else
   b=b;
}
else
         b=b;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout<<setprecision(2)<<b;
return 0;
}

 

 

 

I am new to codechef. just

adarshbl @ 26 Dec 2010 09:46 PM

I am new to codechef. just came to know about it today and started submitting a program. In my comp it is working fine for all the test results. But on CodeChef it is showing Runtime Error (NZEC). i submitted so many times and i am losing interest. can anybody tell whats wrong with my code.

 

public class Main {

 

public static void main(String[] args) throws java.lang.Exception {

float withdraw =0.00f;

int balance=0;

java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));

String input [] =r.readLine().split(" ");

withdraw = Float.parseFloat(input[0]);

balance = Integer.parseInt(input[1]);

if((withdraw<=2000 && withdraw>=0)&& (balance<=2000 && balance>0) && (balance+0.50>withdraw)&& (withdraw%5==0 && balance%5==0) )

{

System.out.println(balance-withdraw-0.50);

}

else

{

System.out.println(withdraw);

}

}

}

You should really test your

triplem @ 27 Dec 2010 02:14 AM

You should really test your code before asking for help. It throws an exception when run on any of the sample inputs provided.

import java.io.*; import

vibhavsingh @ 6 Jan 2011 08:51 PM

import java.io.*;

import java.util.*;

class atm

{

public static void main(String args[]) throws IOException

{

int ia;

String p="";

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

try{

p=br.readLine();

 

StringTokenizer st = new StringTokenizer(p, " ");

 

String o;

o=st.nextToken();

int f =Integer.valueOf(o).intValue();

 

 

String l= st.nextToken();

 

double d = Double.valueOf(l).doubleValue();

 

 

if((0<f&&f<2000)&&(0<d&&d<2000))

{

 

if(f>=d||f%5!=0)

{

System.out.println(d);

}

 

else

{

 

System.out.println(d);

 

}

 

}

 

}

catch(NumberFormatException e)

{

}

catch(NoSuchElementException w)

{

}

}}

help me out in its precision......

sir stephen i need some help

vibhavsingh @ 6 Jan 2011 11:04 PM

sir stephen i need some help here ...

to use which type of datatype......for "D" i.e balance

out put is coming in one significant digit....

import java.text.*;   import

vibhavsingh @ 7 Jan 2011 01:04 AM

import java.text.*;

 

import java.io.*;

import java.util.*;

class atm

{

public static void main(String args[]) throws IOException

{

 

String p="";

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

try{

p=br.readLine();

 

StringTokenizer st = new StringTokenizer(p, " ");

int f =Integer.parseInt(st.nextToken());

double f1=(double)f;

String l= st.nextToken();

 

 

char[]sr ;

 

sr = l.toCharArray();

 

int p2=0;

for(int index=0; index < sr.length; index++)

{ if(sr[index]=='.')

{

p2=index;

 

 

}

}

 

if(sr.length==p2+3)

{

 

 

 

 

 

 

 

double p1= Double.valueOf(l).doubleValue();

DecimalFormat output= new DecimalFormat("#0.00");

if((0<=f&&f<=2000)&&(0<=p1&&p1<=2000))

{

if((f>=p1)||(f%5!=0)||(f==0))

{

String bang = output.format(p1);

System.out.println(bang);

}

else

{ p1=(p1-f1)-0.50d;

String bang = output.format(p1);

System.out.println(bang);

}

}

}}

catch(NumberFormatException e)

{

}

catch(NoSuchElementException w)

{

}

}}

this is edited programm if any one finds any error or exception tell me

plzzz...

it is as per the requriment..but i m getting a wrong answer error on uploading..

 

so pl z help...............

I am getting a runtime error

sahilsingla @ 13 Jan 2011 04:05 PM
I am getting a runtime error NZEC in following java code: http://www.codechef.com/viewsolution/422440 I am not able to fix my error. can anyone plz tell me how to solve this problem!! Thanx.

I am getting a runtime error

sahilsingla @ 13 Jan 2011 04:06 PM
I am getting a runtime error NZEC in following java code: http://www.codechef.com/viewsolution/422440 I am not able to fix my error. can anyone plz tell me how to solve this problem!! Thanx.

Please read the FAQ. You are

triplem @ 14 Jan 2011 01:58 AM

Please read the FAQ. You are meant to use standard input/output, not other methods of getting input.

i have tried almost 10 times

yashpritsingh @ 15 Jan 2011 07:49 PM

i have tried almost 10 times with every time another can you tell me whats wrong in this:

class ATM{

public static void main(String args[]) throws Exception{

java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));

java.io.PrintStream ps = new java.io.PrintStream(System.out);

String s = br.readLine();

String split[]=s.split(" ");

Integer cash = Integer.parseInt(split[0]);

Double bal = Double.parseDouble(split[1]);

if((bal-0.05)>=cash && cash%5==0)

System.out.printf("%.2fn",(bal-cash-0.50));

else

System.out.printf("%.2fn",bal);

}

}

There's a pretty obvious typo

triplem @ 16 Jan 2011 01:00 AM

There's a pretty obvious typo in your code.

Any comments on this

rajneesh2k10 @ 19 Jan 2011 12:06 PM

Any comments on this stephen?? :P ;)

Wrong solution ? lol   using

merl0t @ 20 Jan 2011 02:40 AM

Wrong solution ? lol

 

using System;

public class DD
{
public static void Main()
{
Double h;

string[] val = Console.ReadLine().Split(' ');

if (Double.Parse(val[0].Replace(".", ",")) % 5 == 0)
{
if (Double.Parse(val[0].Replace(".", ",")) > Double.Parse(val[1].Replace(".", ",")) - 0.50)
{
h = Double.Parse(val[1].Replace(".", ","));
}
else
{
h = Double.Parse(val[1].Replace(".", ",")) - Double.Parse(val[0].Replace(".", ",")) - Double.Parse("0,5");
}
}
else
{
h = Double.Parse(val[1].Replace(".", ","));
}

Console.WriteLine(Convert.ToString(h.ToString("N2").Replace(".", "")).Replace(",", "."));
}



}

import java.util.*; class

chirag_mandot @ 20 Jan 2011 02:43 AM

  1. import java.util.*;
  2. class atm
  3. {
  4. public static void main(String a[])
  5. {
  6. Scanner x=new Scanner(System.in);
  7. float amount;
  8. float balance;
  9. amount=x.nextFloat();
  10. balance=x.nextFloat();
  11. while(amount%5==0 && amount<=balance&&(balance-amount)>.5)
  12. {
  13. balance-=amount;
  14. balance-=.50;
  15. }
  16. System.out.println(balance);
  17. }
  18. nw wts wrong wid dis???
  19. ne1 help???

@stephen : thanx for your

sahilsingla @ 21 Jan 2011 07:35 PM

@stephen : thanx for your guidance. I got my problem

import java.io.*; import

shinja @ 23 Jan 2011 01:54 AM
  1. import java.io.*;
  2. import java.util.*;
  3. class novak
  4. {
  5. public static void main(String args[])throws IOException
  6. {
  7. Scanner s=new Scanner(System.in);
  8. double left=s.nextDouble();
  9. if(left>2000||left<0)
  10. {System.out.println("Invalid entry");
  11. System.exit(0);
  12. }
  13. //initblnc is the initial balance
  14. System.out.println("Enter the amt to withdraw:");
  15. BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
  16. double amt=Double.parseDouble(b.readLine());
  17.  
  18. while(left>amt)
  19. {
  20.  
  21. if(amt%5!=0)
  22. {
  23. System.out.println("Invalid entry");
  24. System.exit(0);
  25. }
  26. else
  27. {
  28. double gone=amt+0.50;
  29. left=left-gone;
  30. System.out.println("The left amount is:"+left);
  31. }
  32.  
  33. System.out.println("Enter the amt to withdraw:");
  34. BufferedReader n=new BufferedReader(new InputStreamReader(System.in));
  35. amt=Double.parseDouble(n.readLine());
  36. if(amt==0)
  37. System.exit(0);
  38. if(left<amt)
  39. {System.out.println("Not enough balance");
  40. System.exit(0);
  41. }
  42. }
  43. }
  44. }
  45. THIS CODE IS GIVING RUNTIME ERROR...
  46. how to remove it???
  47. please help.

#include<stdio.h> #include<co

sonika @ 24 Jan 2011 07:41 PM

#include<stdio.h>

#include<conio.h>

void main()

{

int i;

float j;

clrscr();

printf("enter amount withdrawn and balance:");

scanf("%d %f",&i,&j);

if(i>j || (i%5 != 0))

printf("%.2f",j);

else

printf("%.2f",(j-(i*.50)));

getch();

}

"hey i dont know why it says

ritesh_gupta @ 25 Jan 2011 01:40 AM

"hey i dont know why it says "WRONG ANSWER:

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

int X;

 

 

float x;

float Y;

cout << fixed << showpoint << setprecision(2) ;

 

cin>>X;

cin>>Y;

 

 

x=X;

 

 

 

 

 

 

if((X>0 &&  X<=2000)&&(Y>=0 && Y<=2000))

{

if((X%5==0)  && x<=Y+0.5)

{

cout<<(Y-x-0.5);

 

}

else

{

 

cout << Y;

}

}

 

 

return 0;

}

 

y am i getting a runtime

sweety4 @ 25 Jan 2011 08:29 PM

y am i getting a runtime error?

#include<stdio.h> int

raghu112 @ 25 Jan 2011 08:48 PM

#include<stdio.h>

int main()

{

int x;

float bal,y;

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

if((x%5==0)&&(x+.5<=y))

bal= y-(x+.5);

else

bal=y;

printf("%.2f",bal);

return 0;

}

can any one find the error that crept in this code !!

I am not able to submit my

puneet_50 @ 26 Jan 2011 06:29 PM

I am not able to submit my code.

my

muzahid @ 28 Jan 2011 10:39 PM

my solution

#include<stdio.h>
int main()
    {
        float a,c;
        scanf("%f %f",&a,&c);
        if((int)(a)%5==0&&(a+.5)<=(c))c-=a+.5;
        printf("%.2fn",c);
        return 0;
    }

#include<stdio.h> #include<co

pulkitbnsl @ 29 Jan 2011 12:55 AM

#include<stdio.h>

#include<conio.h>

int main()

{

int a;

float b,c;

scanf("%d%f",&a,&b);

if(a%5==0&&a>0&&a<=2000&&b>0&&b<=2000)

{

if(a<=b+0.50)

c=b-a-0.50;

else

c=b;

}

else

c=b;

printf("%.2f",c);

getch();

return 0;

}

what is the problem with the above written code?
pls reply, i m frustated

if the balance and amount to

swcode @ 2 Feb 2011 11:30 PM

if the balance and amount to be transacted are the same? then what should be the output? should it be a negative result (not a feasible one) or should the balance be returned or should it be a 'no result'?

When submitting a Solution

skullbox @ 4 Feb 2011 03:46 PM

When submitting a Solution (C++ in my case) i'm getting the following error

"You can't submit in this language for this problem. Try link"

Please assit

My solution gives runtime

malhotrarulz @ 5 Feb 2011 01:38 AM

My solution gives runtime error of OTHER type, although I am able to run this on my system? What could be the possible reason? I am using python 3.1.1

#include<stdio.h> void

ppraveenbe @ 6 Feb 2011 09:17 AM

#include<stdio.h>

void main()

{

int m1;

float m2;

printf("enter amount(int) and initial amount(0.00)");

scanf("%d %f",m1,m2);

if((m1>0&&m<=2000)&&(m2>=0&&m2<=2000))

{

if (m1<m2)

{

if (m1%5==0)

printf("%f",m2-m1-0.5;);

else

printf("%f",m2);

}

else

printf("%f",m2);

}

#include <iostream.h>#include

sourabh120912 @ 6 Feb 2011 04:25 PM

#include <iostream.h>
#include <conio.h>

//using namespace std;

void main(){

float Bank_Balance=2000.00;
int Enter_Amount;
char ch;

for(;;){

do{
clrscr();
cout << "n###ATM###n";
cout << "Bank Balance Available is => "<< Bank_Balance;
cout << "nnPlease Enter the Amount In multiples Of 5$nn";
cout << "Enter the Desired Amt. => ";
/*for entering the amount*/
cin >> Enter_Amount;

if(Enter_Amount < 0 || Enter_Amount > Bank_Balance) {
cout << "Invalid Value ... Press any Key to TRY AGAIN";getch();
}
}while(Enter_Amount < 0 || Enter_Amount > Bank_Balance);
clrscr();
/*Checking if the Entered Amt. is proper or not*/
if((Enter_Amount % 5) == 0 ){
Bank_Balance -=(Enter_Amount + .50);
cout << "WithDrawal Amt. is => "<<  Enter_Amount<<"$n";
cout << "Bank Balance Remaining => "<<  Bank_Balance<<"$n";
cout << "nTansaction Successful !!!nPress to Proceed...";
}
/*For consideration in multiples of 5$*/
else
{
cout<<"Invalid Amt.!!!nnPlease Enter the Amount In multiples Of 5$nn";
cout<< "Please Press a Key to Process...nn";

}
getch(); clrscr();
cout << "do you want to Process for more Amount =>";
cin >> ch;
if(ch=='N' || ch== 'n') break;
}
}

what is the problem in my

sourabh120912 @ 6 Feb 2011 06:36 PM

what is the problem in my code why its giving errors ... Please Help !

 

 

#include <iostream>


using namespace std;

int main(){

unsigned int Bank_Balance=120.00;
unsigned int Enter_Amount=30;
float k;    

cin >> Enter_Amount >> Bank_Balance;


if(Enter_Amount > Bank_Balance)
{ cout<<Bank_Balance;
}

else
{
if((Enter_Amount % 5) == 0 )
{
k= Bank_Balance -(Enter_Amount + .50);    
cout<<k;        
}

else
{
cout<<Bank_Balance;    
}    
}



return 0;
}

what is the problem in my

sourabh120912 @ 6 Feb 2011 06:36 PM

what is the problem in my code why its giving errors ... Please Help !



#include <iostream>


using namespace std;

int main(){

    unsigned int Bank_Balance=120.00;
    unsigned int Enter_Amount=30;
    float k;    
    
     cin >> Enter_Amount >> Bank_Balance;
    
        
             if(Enter_Amount > Bank_Balance)
             { cout<<Bank_Balance;
             }
            
         else
         {
             if((Enter_Amount % 5) == 0 )
                   {
                    k= Bank_Balance -(Enter_Amount + .50);    
                        cout<<k;        
                   }
                   
                   else
                {
                       cout<<Bank_Balance;    
                }    
        }
        
                    
    
return 0;
}

sourabh.problem is because of

fluteofcoder @ 18 Feb 2011 08:15 PM

sourabh.problem is because of precision after decimal point

Hint:use iomanip header file to set precision after decimal point

Can anyone pls let me know

antonyajay21 @ 19 Feb 2011 09:27 AM

Can anyone pls let me know how can i optimize this code futher. I'm getting a 'time limit exceeded error'

#include "stdio.h"
void main(void){
int c;
float sum;
for(;scanf("%d %f",&c,&sum);){
if((c%5 !=0) || (sum<c)){
printf("%.2f",sum);
continue;
}   
printf("%.2f",sum-(c+0.5));
}
}

 

You're getting time limit

triplem @ 19 Feb 2011 10:29 AM

You're getting time limit exceeded because your for loop will always run forever.

yes. Thnx

antonyajay21 @ 19 Feb 2011 11:08 AM

yes. Thnx

mine was working perfect wid

maninder1989 @ 21 Feb 2011 09:02 AM

mine was working perfect wid my system but here it is showing wrong answer :(

Well, don't I feel like a

Vorlin @ 21 Feb 2011 08:54 PM

Well, don't I feel like a dumb@$$...at least now I know what to use for all input for future projects. You can't use fopen() or fread() in php for input at www.codechef.com because you need the filename (they use files for sample input and of course, we don't know the names nor the directory structures but that's to be expected). Instead, you gotta use fgets(STDIN) like listed below.

 

while (FALSE !== ($line = fgets(STDIN))) {

// code here for lines read by the interpreter

}

can u chek whats problem in

blacklist007 @ 22 Feb 2011 10:43 AM

  1. can u chek whats problem in that code


    #include<stdio.h> int main() { int x; float g,y; scanf("%d%f",&x,&y); if(x%5==00&&x+0.50<y) {g=y-(x+0.50); printf("%.2f",g); } else if(x%5!=0||x>=y) { printf("%.2f",y); } return 0; }

#include<iostream> using

taipan @ 22 Feb 2011 11:25 AM

#include<iostream>

using namespace std;

int main()

{

//  cout<<"enter the ammont of withdrawaln";

int n;

cin>>n;

//  cout<<"enter the ammount in accountn";

double a;

cin>>a;

if((double)n<a && !(n%5))

{

double b=a-(double)n-0.50;

cout<<b<<endl;

}

else

cout<<a<<endl;

system("pause");

return 0;

}

what's wrong with this??
gives a wrong answer... please help

#include <iostream> #include

k.sampath kumar @ 23 Feb 2011 01:11 AM

#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main()
{
int x;
float y;
cout.precision(2);
cout.setf(ios::fixed,ios::floatfield);
cin>>x;
cin>>y;
if((x>0&&x<=2000)&&(y>=0&&y<=2000))
{
if(x%5==0&&x<y)
{
y=y-x-0.50;
cout<<y;
}
else
cout<<y;

}
return 0;
}

 

 

 

Giving Same Output.....

BUt Saying Wrong Answer.....Iam Frustated.:(:(

Need Help.!!!

WHy Is It so...????

hi i am new here. i have

imanulhuq @ 24 Feb 2011 10:36 PM

hi i am new here. i have solved this in TC thus turbo c. but when i paste the code i am getting compilation error.  i know there are some rules. but what are those?

Rule #1: Don't use Turbo C.

triplem @ 25 Feb 2011 09:37 AM

Rule #1: Don't use Turbo C. It doesn't comply with any of the C standards. You may find some help in the FAQ, but I suggest you get a better compiler.

Can someone please help me.

versionjeel @ 28 Feb 2011 02:42 AM

Can someone please help me. For the first two problems i have submited my code (in java)  I got an compiling error saying: /sources/Main.java:5: class ATM is public, should be declared in a file named ATM.java public class ATM { ^ 1 error

What is this exactly supposed to mean? My compiler (eclipse) is not giving me any error what so ever. This is kinda of getting frustrating. Please help.

 

 

P.S All my solutions are correct and result in the same answer as examples.

You should read the FAQ.

triplem @ 28 Feb 2011 05:57 AM

You should read the FAQ.

<?php $wdraw=0; $tot_amount=0

jaguprabha @ 3 Mar 2011 01:44 PM

<?php

$wdraw=0;

$tot_amount=0;

if(isset($_POST['num']) and isset($_POST['total'])){

$tot_amount=$_POST['total'];

if((($wdraw%5)!=0) or ($tot_amount<($_POST['num']))){

echo "Fail";

}

else{

$tot_amount=$tot_amount-$_POST['num'];

$tot_amount=$tot_amount-0.50;

echo $tot_amount;

}

}

?>

<form id="form1" name="form1" method="post" action="">

<p>

<label for="Enter number"></label>

WithDraw Amount

<input type="text" name="num" id="num" />

</p>

<p>Total Amount

<input type="text" name="total" id="total" />

</p>

<p>

<input type="submit" name="button" id="button" value="Submit" />

</p>

</form>

my code is resulting in run

divyark14 @ 5 Mar 2011 09:35 PM

my code is resulting in run time error...... but its executing perfectly well on my compiler.plz help me in identifying the reason............

 

#include<stdio.h>

int main()

{

float X,Y,z;

scanf("%f%f",&X,&Y);

z=(int)X%5;

if(z!=0)

printf("n%0.2f",Y);

else if(X<Y-0.50)

printf("n%0.2f",Y-X-0.50);

else

printf("n%0.2f",Y);

 

return 1;

 

}

@divya make it return 0;

nikunj165 @ 5 Mar 2011 09:57 PM

@divya

make it return 0;

#include<stdio.h>int

rajeevbhardwaj @ 6 Mar 2011 02:37 PM

#include<stdio.h>
int main()
{
int x;
float y;
scanf("%d%f",&x,&y);
if((float)x>y||x%5!=0)
printf("%0.2f",y);
else
printf("%0.2f",y-x-0.5);
return 0;
}
u r giving wrong ans for my code but when i m checking it is giving write for all the inputs i tried.........

can u please tell me what's wrong with it ?

#include <stdio.h> #include

nikhitakataria @ 10 Mar 2011 12:29 AM

#include <stdio.h>

#include <stdlib.h>

 

int main(int argc, char *argv[])

{

int x;

float y;

scanf("%d",&x);

scanf("%f",&y);

if(x>2000 || y>2000 || x<0 || y<0)

{

printf("Invalid");

}

else

if(x%5!=0)

{

printf("Invalid");

}

else

if((x+0.50)>y )

{

printf("Invalid");

}

else

{

y=y-x-0.50;

printf("%.2f",y);

}

system("PAUSE");

return 0;

}

wazz wrong?

Plz help me with this error,

ashu_kataria @ 10 Mar 2011 01:49 PM

Plz help me with this error, it is compiling successfully on NetBeans 3.6

 

/sources/Main.java:13: class AccountBalance is public, should be declared in a file named AccountBalance.java public class AccountBalance { ^ 1 error

 

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package codechef;

/**
*
* @author AsHu
*/
import java.util.Scanner;
public class AccountBalance {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int amount;
float balance;

Scanner sc=new Scanner(System.in);
amount=sc.nextInt();
balance=sc.nextFloat();
if((balance>0 && balance<=2000)&&(amount>=0 && amount<=2000))
if(balance>(amount+.50))
if(amount%5==0)
balance-=amount+.50;
System.out.println(balance);
}

}

 

 

whats wrong in this

kapil_iitbhu @ 12 Mar 2011 04:27 PM

whats wrong in this code???its giving Runtime error during submission.

#include<stdio.h>

main(){

float b;int a,c;

scanf("%d%f",&a,&b);

if(a%5!=0||a>b||b<5.5)

printf("%fn",b);

else{

b=b-a-0.50;

printf("%fn",b);

}

}

#include <iostream>   using

sushil0111 @ 16 Mar 2011 11:12 PM

#include <iostream>

 

using namespace std;

 

int main()

{

int x;

float y;

cout<<"enter the money you want to withdraw::";

cin>>x;

cout<<"enter the total account balance";

cin>>y;

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

{

cout<<"account balance::";

cout<<(y-x-0.50);

}

else

if((x%5)!=0)

cout<<"please enter the multiple of 5::nAccount balance::"<<y;

else

if(x>y)

cout<<"Account balance::"<<y;

else

cout<<"WRONG ENTRY";

 

 

}

#include<conio.h> #include<io

sharadr19 @ 22 Mar 2011 07:51 PM

#include<conio.h>

#include<iostream.h>

class Atm

{

int x

int am;

float y;

public:

void get();

void calculate();

void show();

};

void Atm::get()

{

cout<<"Enter Amount for Transaction and ur Account Balance";

cin>>x>>y;

}

void Atm::calculate()

{

if(x>=y)

{

am=y;

cout<<"You Have Insufficient Balance"<<am;

}

else if(y%5==0)

{

am=(y-x)-0.50;

}

else

{

cout<<"U HAve Entered Incorrect Amount";

am=0;

}

}

void show()

{

cout<<"Now Your Account Balance is";

cout<<am;

}

main()

{

Atm A;

A.get();

A.calculate();

A.show();

getch();

}

Hello I'm new here. Please

cheddo @ 23 Mar 2011 11:13 AM

Hello I'm new here. Please tell me why this code is wrong :)

<?php

function withdraw($amount,$balance) {

if(($amount%5==0)&&($amount+0.50<=$balance)) {

$balance -= ($amount+0.50);

}

settype($balance,"float");

echo $balance;

}

if((0<$amount)&&($amount<=2000)) {

if((0<$balance)&&($balance<=2000)) {

withdraw($amount,$balance);

}

}

?>

why this program get wrong

cheddo @ 24 Mar 2011 04:19 AM

why this program get wrong answer?

 

<?php

if(($x%5==0)&&($x+0.50<=$y)) {

$y = $y-$x-0.50;

}

printf("%.2f",$y);

?>

 

Please help me, I'm newbie. T__T

Please help me anyone.Why the

hopeful @ 26 Mar 2011 11:43 PM

Please help me anyone.Why the program ATM getting wrong answer?

@Prathak: your code is not

girish_l @ 28 Mar 2011 06:09 PM

@Prathak: your code is not accepting any values,  use fgets(STDIN) to accept values

Can anyone tell me what is

pcxor @ 1 Apr 2011 12:13 AM

Can anyone tell me what is the problem with this code. The online compiler is giving me a runtime error.

 

#include <stdio.h>
int main()
{
int w_amount; // Withdrawal oamount
float ini_bal; // Initial Balance

scanf("%d %f", &w_amount, &ini_bal);
if(ini_bal<(w_amount+.5) || (w_amount%5 !=0)) {
printf("%.2fn",ini_bal);
}
else
printf("%.2fn",ini_bal-(w_amount+.5));
}

To Admin, You should make it

quentin_proust @ 1 Apr 2011 12:45 AM

To Admin,

You should make it explicit that we shouldn't take care of internationalization. I was typing 120.00 (with a point) and replacing the point by a comma so that C# could parse it as a decimal. And it gave me wrong answer.

I had to look at a successfull sumbit that wasn't working for me to understand.

#include <iostream> #include

foolingup @ 9 Apr 2011 11:43 AM

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{int wid;

float bal;

cin>>wid>>bal;

if((wid%5)==0)

{if(wid<bal)

{bal=bal-wid;

bal-=0.50;

cout<<fixed<<setprecision(2)<<bal;

}

else

cout<<fixed<<setprecision(2)<<bal;

}

I have got the above code working perfectly still when i submit i get wrong answer ....Mr admin whats the problem ????

void main(){ int

summved @ 11 Apr 2011 11:51 PM

void main()
{
int wd,tot,rem=0;
printf("Enter the total amount");
scanf("%d", &tot);
printf("Enter amount withdrawn");
scanf("%d", &wd);

if(tot>wd)
{
if(wd%5==0)
{
rem=tot-(wd+.50);
printf("Your Balance is = %d",rem);
}

else
printf("Not correct amount to withdraw");
}

else
printf("Total cant be more than Withdrawl amount");

}

This problem can't be

miki208 @ 12 Apr 2011 07:01 PM

This problem can't be resolved..

#include<stdio.h> #include<co

master_coder @ 14 Apr 2011 12:00 PM

#include<stdio.h>

#include<conio.h>

void main()

{

float y,total;int x;

printf("Enter the cash to withdarw and initial balancen");

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

 

if((x<=2000)&&(y<=2000))

{

if(x>y)

printf("Insufficent fundsn");

else

if(x%5!=0)

{

printf("Incurrect withrawal ammount(not multiple or 5)n");

}

else

{

total=(y-x)-.50;

printf("Transection succesfuln%.2f",total);

}

}

getch();}

on executing 5.51-(5+.5) its

aadish26 @ 14 Apr 2011 02:14 PM

on executing 5.51-(5+.5) its giving 009999999999999787 which is according to you a wrong ans? i think...

can anyone tell me why wrong

aadish26 @ 14 Apr 2011 03:15 PM

can anyone tell me why wrong ans?

 

import java.text.DecimalFormat;

import java.util.Scanner;

class ATM {

public static void main(String[] args) throws Exception{

Scanner s=new Scanner(System.in);

java.text.DecimalFormat df=new DecimalFormat("####.##");

int n=s.nextInt();

double m=s.nextDouble();

if((m>0)&&(m<=2000)&&(0<n) &&(n<=2000))

{

if((n%5==0) &&((n+0.50)<=m))

{

m=m-n-0.50;

m=df.parse(df.format(m)).doubleValue();

System.out.println("balance is"+m);

}

else{

System.out.println(m);

}

}

else{

System.out.println("wrong value");

}

}

}

no check for  (0 < X <= 2000)

aadish26 @ 14 Apr 2011 06:35 PM

no check for  (0 < X <= 2000) &&(0 < y <= 2000)

in accepted programs i've added this check n i'm wrong lolzzzz:)

#include<iostream.h>#include<

newdeveloper @ 15 Apr 2011 02:25 PM

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>

void main()
{
float x = 120.00;
int y;
clrscr();
cout<<"Enter withdraw ammount & balance";
cin>>y>>x;
if(x>2000 | y>2000)
{
cout<<"Wrong input";
getch();
exit(0);
}
if(y%5!=0)
{
cout<<"Wrong enter withdraw ammount";
getch();
exit(0);
}
else if(y>=x)
{
printf("insufficient ammount = %.2f",x);
getch();
exit(0);
}
else
{
x = x-y-.5;
printf("total ammount = %.2f",x);
getch();
}
}

#include<iostream.h>#include<

newdeveloper @ 15 Apr 2011 03:45 PM

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>

void main()
{
float x = 120.00;
int y;
clrscr();
cout<<"Enter withdraw ammount & balance";
cin>>y>>x;
if(x>2000 | y>2000)
{
cout<<"Wrong input";
getch();
exit(0);
}
if(y%5!=0)
{
cout<<"Wrong enter withdraw ammount";
getch();
exit(0);
}
else if(y>=x)
{
printf("insufficient ammount = %.2f",x);
getch();
exit(0);
}
else
{
x = x-y-.5;
printf("total ammount = %.2f",x);
getch();
}
}

Yaar dis code is running on

bharat0109i @ 21 Apr 2011 02:44 AM

Yaar dis code is running on my comp but here it is giving wrong answer if u know what can be the error pls post.



import java.io.*;
class atm{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
String words[] = line.split(" ");
int tran = Integer.parseInt(words[0]);
double balance = Double.parseDouble(words[1]);
if(tran%5!=0) System.out.println(String.format("%1$.2f",balance));
if(balance-0.50-tran<0)System.out.println(String.format("%1$.2f",balance));
if(balance-0.50-tran>=0 && tran%5==0) System.out.println(String.format("%1$.2f",balance-0.50-tran));
}
}

import

tdmonk1 @ 4 May 2011 08:15 AM

import java.util.Scanner;

 

public class Main

{

 

public static void main(String[] args)

{

Scanner atm = new Scanner(System.in);

int withdraw = atm.nextInt();

float balance = atm.nextFloat();

if(withdraw%5 == 0 && withdraw < balance)

System.out.println(balance-withdraw-.50);

else

System.out.println(balance);

 

}

 

}

 

I don't get it I run this code in eclipse and it works perfect with the right answer but the submission on this site keeps on saying wrong answer

#include<stdio.h> int

ronakag @ 12 May 2011 03:12 PM
#include<stdio.h>
int main()
{
int x;
float y;
scanf("%d",&x);
scanf("%f",&y);
 
if(x%5==0 && x+0.50<=y)
printf("%.2f",y-x-0.50);
else
printf("%.2f",y);
}


#include<stdio.h> int main() { int x; float y; scanf("%d",&x); scanf("%f",&y); if(x%5==0 && (y-x-0.50>=0)) printf("%.2f",y-x-0.50); else printf("%.2f",y); }

What is the differnence between
x+0.50<=y
y-x-0.50>=0

I am able to execute the first one but not the second one...:(

what's wrong with

claudiotreme @ 13 May 2011 04:35 AM

what's wrong with mine??

please help!

 

#include <stdio.h>
int main (void)
{
int X;
float Y; 
//withdraw value
scanf ("%d",&X); 
//account balance
scanf ("%f",&Y);
if (X>=Y){
printf("%.2f",Y);
} else {
if ((X<(Y+0.50)) && ((X%5)==0) && (0<X<=2000)){
Y=Y-(X+0.50);
printf ("%.2f",Y);
}else{
printf("%.2f",Y);
}
}
return 0;
}

what's wrong with

claudiotreme @ 13 May 2011 04:35 AM

what's wrong with mine??

please help!

 

#include <stdio.h>
int main (void)
{
int X;
float Y; 
//withdraw value
scanf ("%d",&X); 
//account balance
scanf ("%f",&Y);
if (X>=Y){
printf("%.2f",Y);
} else {
if ((X<(Y+0.50)) && ((X%5)==0) && (0<X<=2000)){
Y=Y-(X+0.50);
printf ("%.2f",Y);
}else{
printf("%.2f",Y);
}
}
return 0;
}

Why does it give runtime

ashutosh30492 @ 22 May 2011 10:23 PM
Why does it give runtime error for the following? #include main() { int n; float balance; scanf("%d %f", &n, &balance); if((n%5==0) && (n

Why does it give runtime

ashutosh30492 @ 22 May 2011 10:24 PM
Why does it give runtime error for the following? #include main() { int n; float balance; scanf("%d %f", &n, &balance); if((n%5==0) && (n

#include main() { int n;

ashutosh30492 @ 22 May 2011 10:24 PM
#include main() { int n; float balance; scanf("%d %f", &n, &balance); if((n%5==0) && (n

It gives me a runtime error

ashutosh30492 @ 22 May 2011 10:45 PM
It gives me a runtime error if I have used main() { /*program*/ } but correct answer if I use int main() { /*program*/ return 0; } Can someone explain why this happens?

#include int main() { int

garima_mishra @ 23 May 2011 01:15 PM
#include int main() { int wamt; float amt; scanf("%d%f",&wamt,&amt); if(wamt<=amt&&(wamt%5==0)) printf("%0.2f",(amt-(wamt+0.50))); else printf("%0.2f",amt); return 0; } i am not able to debug it...plz help

'm getting a run-time error

ks_dharanish @ 27 May 2011 05:31 PM
'm getting a run-time error for "only god knows why" reasons....

What is meaning of "problem

rameshwar @ 30 May 2011 03:54 PM
What is meaning of "problem HS08TEST" My program is able to solve this problem and give correct out put in my laptop as given but why it is showing time error in ....

Hi, my submitted solution is

girish1026 @ 30 May 2011 06:47 PM
Hi, my submitted solution is as below. #include int main(void) { int amt; float bal; printf("Enter amount to be withdrawn and balancen"); scanf("%d%f",&amt,&bal); if((float)amt

my program is running in dev

spikeone @ 31 May 2011 02:38 PM
my program is running in dev c++....but here its showing wrong answer..!!!

my program is running in dev

spikeone @ 31 May 2011 02:39 PM
my program is running in dev c++....but here its showing wrong answer..!!!

my program is running

adiki @ 3 Jun 2011 10:29 PM
my program is running properly in devc but getting a runtime error over here..may i know d mistake..

#include int main() { int

ashishyogi @ 10 Jun 2011 06:10 PM
#include int main() { int x; float y,z,s; scanf("%f",&y); scanf("%d",&x); if(x%5==0&&(x+.5)0&&y>0) { z=x+.5; s=y-z; printf("%f",s); return 0; } printf("%f",y); return 0; } wats d problem in this soln.....its giving me wrong answer...:(:(tried to submit it about 20 tyms

hi Guys ,, i have made prog

rahul1n9 @ 25 Jun 2011 03:00 PM
hi Guys ,, i have made prog giving right answer as given solution but it is saying wrong anwer,..Can anyone sort out this

@adiki....hope u r not

rahul1n9 @ 25 Jun 2011 03:02 PM
@adiki....hope u r not including Conio.h or getche smthing functions in prog

dont know whats the problem!!

anup1912 @ 27 Jun 2011 02:57 PM
dont know whats the problem!! just shows runtime error and no specific codes for the error... i am running it in my computer and its running just as fine but here it shows error...do the inputs need to be whitespace seperated? #! usr/bin/python3.0 x=int(input()) y=float(input()) if 0<=x<=2000 and 0<=y<=2000: if x>(y-1): print(y) elif x%5==0: print(y-x-0.50) elif x%5!=0: print(y)

hello, I've been trying to do

rajeshkadp @ 28 Jun 2011 11:36 PM
hello, I've been trying to do this problem with Perl. My solution in Perl for the previous problem worked fine. So it's not an interpreter issue. Though my program works perfectly fine in my machine, I'm getting a 'wrong answer' error when i write the same code here. I've tried multiple methods. I've even taken the correct solution and adopted the same logic in vain attempts to get my code working. Could you please help or put up some working Perl code? I couldn't a single Perl solution in the successful solutions list. P.S. I've gone through the FAQs multiple times too.

still posting the correct

ashok_thepower @ 30 Jun 2011 07:02 AM
still posting the correct answer program working fine still wrong answer !!!!!!!!!!!!!!!!!!!1

I get a runtime error with

s532104 @ 30 Jun 2011 03:36 PM
I get a runtime error with this: are we not allowed to use "return(EXIT_FAILURE)" ? #include #include #define ATM_FEE 0.5 #define MAX 2000 #define MIN 0 int main() { int withdraw=0; float balance=0; scanf("%d%f",&withdraw, &balance); if ((withdraw MAX) && ((balanceMAX))) return(EXIT_FAILURE); if (withdraw%5!=0) return (EXIT_FAILURE); balance=balance-withdraw-ATM_FEE; if (balance<0) return (EXIT_FAILURE); printf("%.2fn",balance); return (EXIT_SUCCESS); }

whoops, nevermind didn't see

s532104 @ 30 Jun 2011 04:14 PM
whoops, nevermind didn't see the outputs for case 2 and 3

can anyone tell me , what's

chandrathebest @ 1 Jul 2011 09:43 PM
can anyone tell me , what's wrong in this code: #include main() { int w;float b; scanf("%d %f",&w,&b); if(w>(b-0.5)) printf("n%.2f",b); else if(w%5!=0) printf("n%.2f",b); else printf("n%.2f",(b-w)-0.5); }

Wrong Answer

fakeerfaquir @ 3 Jul 2011 09:21 AM
Wrong Answer again!!! Why? #include int main() { int x; float y,sum; scanf("%d%f",&x,&y); if (x%5==0&&!(y<=2000)&&(x<=y-0.5)) { sum=y-x-0.5; printf("%.2fn",y); } else printf("%.2fn",y); return 0; }

hi admin. i tried.. and got

prashant_d_1 @ 5 Jul 2011 12:49 AM
hi admin. i tried.. and got wrong...as result from codechef compiler.. after that i tried it checking the solution and just changed the io method.. it worked.. so i think updating the way input is given in question might help a lot of beginners like me.. :)

#!/bin/bash #set -x if [

nishajib @ 6 Jul 2011 01:02 PM
#!/bin/bash #set -x if [ `echo "$1%5"|bc` = 0 ] then if [ $1 -gt 0 -a $1 -lt 2001 ] then if [ $2 -gt 0 -a $2 -lt 2001 ] then if [ $2 -gt $1 ] then #a=`echo "scale=2;$2-$1.49"|bc` a=`echo "$2-$1.49"|bc` echo $a else echo $2 fi else echo $2 fi else echo $2 fi else echo $2 fi ~ #!/bin/bash #set -x if [ `echo "$1%5"|bc` = 0 ] then if [ $1 -gt 0 -a $1 -lt 2001 ] then if [ $2 -gt 0 -a $2 -lt 2001 ] then if [ $2 -gt $1 ] then #a=`echo "scale=2;$2-$1.49"|bc` a=`echo "$2-$1.49"|bc` echo $a else echo $2 fi else echo $2 fi else echo $2 fi else echo $2 fi ~ whats wrong with that

WTF it is giving wrong answer

prabal77 @ 10 Jul 2011 01:02 AM
WTF it is giving wrong answer error all the time. i have tested various conditions. I guess admin should reply on this. this is my code. i dont; think it is wrong anywhere. import java.text.NumberFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double withdrawal = in.nextDouble(); double totalAmount = in.nextDouble(); if(withdrawal%5 != 0 || (totalAmount < (withdrawal+0.50))){ System.out.println(""+roundOffNumber(totalAmount)); }else{ System.out.println(""+roundOffNumber((totalAmount-(withdrawal+0.50)))); } } public static String roundOffNumber(double d){ NumberFormat frmt = NumberFormat.getInstance(); frmt.setMaximumFractionDigits(2); frmt.setMinimumFractionDigits(2); return frmt.format(d); } }

import

prabal77 @ 10 Jul 2011 02:30 AM
import java.text.NumberFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double withdrawal = in.nextDouble(); double totalAmount = in.nextDouble(); if(withdrawal%5 != 0 || (totalAmount < (withdrawal+0.50))){ System.out.println(""+roundOffNumber(totalAmount)); }else{ System.out.println(""+roundOffNumber((totalAmount-(withdrawal+0.50)))); } } public static String roundOffNumber(double d){ NumberFormat frmt = NumberFormat.getInstance(); frmt.setMaximumFractionDigits(2); frmt.setMinimumFractionDigits(2); return frmt.format(d); } }

import java.io.*; class

kasim @ 11 Jul 2011 12:48 AM
import java.io.*; class ATM { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Input"); double widraw = Double.parseDouble(br.readLine()); double total = Double.parseDouble(br.readLine()); double output = 0; System.out.println("n"); if (widraw % 5 == 0 && (total - widraw) >= 0.5) { output = total - widraw - 0.5; } System.out.println("Outputn" + output); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } } } //try it works

Hi, I have just entered a

mani_surolia @ 13 Jul 2011 04:28 PM
Hi, I have just entered a solution for this in BASH. and it shows as wrong answer. Can you please check and and let me for which test case it fails? Thanks,

Hey guys! If you're getting

douglas @ 15 Jul 2011 09:55 AM
Hey guys! If you're getting "Wrong Answer", and using C, choose C99 Strict instead of C. It works for me in these situation. =)

I mean, in these

douglas @ 15 Jul 2011 09:55 AM
I mean, in these situations...
1 of 2
next ›

SUCCESSFUL SUBMISSIONS


Fetching successful submissions

HELP



Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

 

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.

  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.

  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.

  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.

  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.

  • If you are still having problems, see a sample solution here.
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.