You are not logged in. Please login at www.codechef.com to post your questions!

×

How to get rid of NZEC error in Python?

for item in range(int(input())):
    a,b=map(int,input().split())
    s='^'.join([str(i) for i in list(range(a,b+1))])
    if eval(s)%2==0:
        print('Even')
    else:
        print('Odd')

Whats wrong in this code? showing the runtime error

asked 10 Feb, 17:07

godson_gsn's gravatar image

0★godson_gsn
1
accept rate: 0%


One possible reason is the difference between a and b is too much and you are not able to allocate this much of memory. You can't have a string of size more than $10^8$. But if $a =1$ and $b = 10^9$ then it's surely going to give such error. Check the constraint on $a, b$. Good approach can be this.

link

answered 10 Feb, 19:05

vichitr's gravatar image

5★vichitr
2555
accept rate: 11%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×26
×14

question asked: 10 Feb, 17:07

question was seen: 55 times

last updated: 10 Feb, 19:05