1 / 6
Jul 2011

def solve(line):
    sqs = map(lambda x: float(x) ** 2, line.strip().split())
    print '%.4f' % ((1/144.0) * (sqs[0]*sqs[4]*(sqs[1]+sqs[2]+sqs[3]+sqs[5]-sqs[0]-sqs[4]) + sqs[1]*sqs[5]*(sqs[0]+sqs[2]+sqs[3]+sqs[4]-sqs[1]-sqs[5]) + sqs[2]*sqs[3]*(sqs[0]+sqs[1]+sqs[4]+sqs[5]-sqs[2]-sqs[3]) - sqs[0]*sqs[1]*sqs[3] - sqs[1]*sqs[2]*sqs[4] - sqs[0]*sqs[2]*sqs[5] - sqs[3]*sqs[4]*sqs[5]))**0.5
def main():
    from sys import stdin
    stdin.next()
    [solve(x) for x in stdin]
main()

It's 'print' line that raises the exception, and it isn't neither ValueError nor IndexError. I tested the code at ideone.com with different test-cases, it works fine. What can be the problem.

  • created

    Jul '11
  • last reply

    Aug '11
  • 5

    replies

  • 266

    views

  • 2

    users

  • 2

    links

12 days later

I suppose you get a negative radicand for some input data. Using an additional abs() should give WA instead of NZEC.

Still NZEC. And as I said I tried to catch ValueError, it's another exception.