Problem : A. Theatre Square
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.
What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square
import math
n=int(input())
m=int(input())
a=int(input())
if a>=1 and a<=10**9:
square=a
if m>=1 and m<=10**9:
length=m
if n>=1 and n<=10**9:
width=n
total=math.ceil(length/square)*math.ceil(width/square)
print(total)
This code runs fine in my IDE,but gives error when I submit the answer. What to correct?
input()
reads a line, the input in this problem is one line with three integers.So you need to use
n,m,a = map(int,input().split())
And by the way, you can assume that the input limits are correct you don't need to check that when solving a problem.
Input is given as three integers on a single line, but you are trying to read it as if you are given three line with one integer on each line. That makes a great difference for Python, because
input()
reads a whole line.Instead of
try using
ok what about this from numpy import array a=-1 n=int(input("")) c=False A=array([int]*n) for i in range(n): A[i]=int(input("")) b=int(input("")) for i in range(n): if(A[i]==b): print(i) c=True if(c==False): print(a)