HS08TEST - Editorial

#include
using namespace std;

int main()
{
int withdraw;
float balance;
cin>>withdraw;
cin>>balance;
if((withdraw % 5 == 0) && (withdraw + 0.50) < balance)
printf("%.2f",balance - withdraw - 0.50);
else
printf("%0.2f", balance);
return 0;
}

why this code is wrong??

Here is the 2 liners for this having an execution time of 0.00 seconds.
Here is the code:

#include<bits/stdc++.h>

using namespace std;

int main(){

int x; cin>>x;

double y; cin>>y;

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

cout<<fixed<<setprecision(2)<<double((y-x)-0.5);

else cout<<fixed<<setprecision(2)<<y;

}

Can someone tell me what’s wrong with my code?

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

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner s=new Scanner(System.in);
int n=s.nextInt();
double f=s.nextDouble();
if(n%5==0&&n<f)
f-=n+0.5;
System.out.printf("%.2f",f);
}
}

+0.5 cuz 120 - (x+0.5) == 120 - x - 0.5
120 - 30.5
right?

#include<stdio.h>

int main()

{

int x;

float y;

printf("Enter withdraw amounte & balance: ");

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

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

{

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

    {

        y=y-x-0.5;

    }

printf("Pooja's Bank Balence: %0.4f",y);

}

return 0;

}
// what is problem in this case