gray9's blog

By gray9, 11 years ago, In English

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.

Tags c++
  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
11 years ago, # |
  Vote: I like it +13 Vote: I do not like it

why "return 1" in the end?

»
11 years ago, # |
  Vote: I like it +8 Vote: I do not like it

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......!

»
11 years ago, # |
  Vote: I like it +10 Vote: I do not like it

" return 0; " should turn your RE into WA.

»
11 years ago, # |
Rev. 3   Vote: I like it -9 Vote: I do not like it

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

else {
			if((a+b)<=0)
				break;
			minop++;

How can I solve it. Does any data variable support 10^18.