Search code examples
pythonpython-2.7raw-inputeoferror

Traceback (most recent call last) EOFError


here is my code

t=input()
for q in range(t):
  s=raw_input()
  m,n=s.split(' ')
  ans = (m*n)*(m*n-1)
  if(m>1 and n>1):
    ans -= 4*(n-1)(m-2) + 4*(m-1)*(n-2)
  print ans

It has the error

Traceback (most recent call last):
  Line 1, in <module>
  t=raw_input()
 EOFError

What am i doing wrong ? please tell me here's the link

http://codepad.org/nmL96e68


Solution

  • This is probably what you want to achieve, supposing m and n are integer type values,

    t = input()
    for q in range(t):
        s = raw_input()
        m, n = map(int, s.split(' '))
        ans = (m * n) * (m * n - 1)
        if m > 1 and n > 1:
            ans -= 4 * (n - 1) * (m - 2) + 4 * (m - 1) * (n - 2)
        print ans