lundi 22 mai 2017

Runtime error on Online Judge (Live Archive) [on hold]

I am solving 6176 - Faulhaber's Triangle and getting Runtime Errors. I manage to reduce it to a couple of lines (using an already AC code).

if( b < 0 ){
  a *= -1;
  b *= -1;
}
n=a;
d=b;

where a, b, n, d are long long; a, b are parameters and n, d are members of struct frac (from fraction) inside the constructor. I'm trying to "move" the sign to the numerator (-a/-b -> a/b, a/-b -> -a/b, ...). AC code:

ll sgn;
if(a*b<0)
  sgn = -1;
else
  sgn = 1;
a = llabs(a);
b = llabs(b);

n = sgn*a;
d = b;

I check the correctness of my code comparing its output with the AC code output for all possible inputs (~400*400/2).

Full Runtime Error code

AC code

In my configuration there was no errors: Windows 10, 64-bits, g++ (GCC) 5.3.0 mingw. According to Live Archive:

C++11 5.3.0 - GNU C++ Compiler with options: -lm -lcrypt -O2 -std=c++11 -pipe -DONLINE_JUDGE

Aucun commentaire:

Enregistrer un commentaire