n,k =map(int,input().split(" "))
j=0
for i in range(n):
if((int)(input()))%k==0:
j=j+1
print(j)
The code works well in my system but on submitting it I get a TLE error in Python 3.1.2 . On submitting in python 2.7.2 it gave nsez error.I tried using
It gave TLE in 3.1 because 3.1 is very slow for this question even though code is correct. Nothing you can do.
For version 2.7.2 you will need to replace the input() by raw_input() since input() is used to input only numbers and not strings. raw_input() is used for strings.
the method he told ou is the correct way to take input in python 2.7 and earlier versions. he has mentioned in answer that this cant not be solved in python. try it in C or C++ (using scanf and printf) python I/O is very slow so its not solvable in python.
i just chekd the accepted codes and there are a few in python. so it s solvable but using some faster I/O methods. ur code is correct but for it to pas in time limit it requires some tricks.see this one http://www.codechef.com/viewsolution/3950420
but stil there will be a few questions in some contests where the time limit will be strict and a python code will never be ale to get AC even with the most efficient algo. so better use C or C++ in contests.
@akshitha007 It is because the Python installed on your system is version 2.7 and not 3.1 as you think. I tested both the codes above on ideone.com and here are the links:
Thanks a lot.
Actually I was running the code on 3.3.2 and I thought that it must be the same as 3.1.
In that case please let me know how to take faster input and output in python 2.7…as I come across many problems that run well on my system but I get a TLE or NSEZ on the site.