Isn’t it supposed to be
b >= (a + 0.50) ?
Isn’t it supposed to be
b >= (a + 0.50) ?
Thank you, Code has been successfully submitted.
#include<bits/stdc++.h>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int x;
cin >> x; //withdrawl balance
float y;
cin >> y; //Total balance
float result=0;
if ((x % 5 == 0) && (y<x+0.50) {
result = y - (x + 0.50);
} else {
result = y;
}
cout << result << endl;
return 0;
}
please explain why it is giving me wrong answer?
#include
using namespace std;
int main() {
int x;
float y;
cin>>x>>y;
if(x%5==0 && x+0.5<y) {
printf("%.2f\n",y-x-0.5);
}
else {
printf("%.2f\n",y);
}
return 0;
}
Hello, what is wrong with this code? I tested a couple of numbers and the results are correct. Thanks!
Consider the test input:
5 5.50
You should at least look at previous posts/comments in the discussion.
#include <iostream>
using namespace std;
int main(){
int x; // x -> withdraw;
float y; //y -> current ballance
cin >> x;
cin >> y;
if(x>0 && x<=2000 && y>=0 && y<=2000){
if(x%5 == 0 && (x + 0.50f) < y){ // successful transition
cout << y-(x + 0.50f); // current amount
}
else{ // not a multiple of 5 or x+0.5>=y
cout << y; //
}
}
else{
cout << y;
}
return 0;
}
when I am running it with custom input the output is coming correct, but when i am submitting it it’s saying “wrong answer”
it will be a great help you can tell me what i am doing wrong
give the input by yourself
Hi, everyone!
Please tell my why i always get TimeLimit Exeption (0.21sec) when “submit” my code. But when i just “Run” it goes fast (for exmpl 0.06 sec).
Well, even if I try to use best code from solutions, i still get TL (0.21sec)
process.stdin.resume();
process.stdin.setEncoding(‘utf8’);
// your code goes here
process.stdin.on(“data” , (chunk) => {
const input = chunk.split(" ");
const amount = parseInt(input[0]);
const balance = parseInt(input[1]);
const fee = 0.5;
let output = balance;
if(balance >= (amount + fee) && amount % 5 === 0){
output = balance - amount - fee;
}
console.log(output.toFixed(2));
});
#include
using namespace std;
int main() {
int x;
cin>>x;
float y;
cin>>y;
if((x%5==0) && (y>(x+0.50)))
cout<<(y-x-0.50);
else
cout<<y;
return 0;
}
can anyone tell me what’s wrong in this??
You should have checked previous comments before posting your code and ask for help.
using namespace std;
int main() {
int with_amount ;
float totalAmount;
cin>>with_amount;
cin>>totalAmount;
if((with_amount>0 && with_amount<=2000)&&(totalAmount>=0 && totalAmount<=2000)){
if (with_amount>=totalAmount){
cout<<fixed<<setprecision(2)<<totalAmount;
}
else if(with_amount%5==0){
totalAmount-=0.5;
cout<<fixed<<setprecision(2)<<totalAmount-with_amount;
}
else if(with_amount%5!=0){
cout<<fixed<<setprecision(2)<<totalAmount;
}
}
return 0;
}
what’s wrong in this code??
You should have gone through the previous comments before posting your query!!
#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
#include
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x;
float y,c=0.50;
cin>>x;
cin>>y;
if( x>0 && x<= 2000 && y>=0 && y<=2000){
if(x%5==0){
if((x+c)<y){
// cout<<y-(x+c);
cout << fixed << setprecision(2)<<y-(x+c)<<endl;
}else{
cout<<fixed << setprecision(2)<<y;
}
}else{
cout<<fixed << setprecision(2)<<y;
}
}else{
return 0;
}
// return 0;
}
please define error in this code