Answer the question
In order to leave comments, you need to log in
In which case the program produces a false result?
I was solving problems and I had a problem when solving this one:
#include <iostream>
using namespace std;
int main()
{
int x,n,t;
double t2;
cin » n » x » t;
t2 = (double)(n*t)/x;
t = (n*t)/x;
if(t < t2) {
cout « t+1 « endl;
} else {
cout « t « endl;
};
return 0;
}
Answer the question
In order to leave comments, you need to log in
T = 4, X = 2, N = 1. 2 minutes are obtained, although four are needed.
You don't need ceilDiv(nt, x), at ceilDiv(n,x).
Well, with such restrictions ceilDiv(n, x) = (n + x - 1) / x, without fractional arithmetic.
(When collecting everything into one expression, don't forget the parentheses!)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question