I am getting below run time error in Codeforces, though code works as expected in my local compiler. Time: 0 ms, memory: 0 KB Verdict: RUNTIME_ERROR
I submitted my code for http://codeforces.com/contest/317/problem/A
Code is below.
#include <iostream>
using namespace std;
int main(){
double a,b,n;
cin >> a >> b >> n;
int minop=0;
while(true){
if((a >= n) || (b >= n))
break;
else {
if(a<=0 || b <=0)
break;
minop++;
if(a>b)
b=a+b;
else
a=a+b;
}
}
if(minop==0) minop=-1;
cout << minop;
return 1;
}
Unable to understand the error. Please suggest how to solve it.
why "return 1" in the end?
Jury checks the exit code of your problems, if the code is 0, it means that the programs works properly and ends successfully....but if the exit code is something else, it means that the program does not exited successfully ... and now your program exits with code 1......!
" return 0; " should turn your RE into WA.
Thanks for pointing out. I get Wrong Answer on test 5 when I'm submitting. Changes are returning 1 at program end and else block
How can I solve it. Does any data variable support 10^18.
long long, long double
double stores 15-16 digits
Thanks
Why do u write (a+b)<=0 there? For example, pair (-3, 2) can be made 5-perfect (even tho -3+2<0):
(-3,2) -> (-1,2) -> (1,2) -> (3,2) -> (3,5)