INTEST: Getting rte

Using Python

c, d = raw_input().split
a = float(c)
b = float(d)
var = 1
lol = 0
success = 0

for times in range(0,number):
	number = raw_input
	e = float(number)
	while var == 1:
		if e % b == 0:
			success += 1
			var -= 1
			lol += 1
		if e % b != 0:
			success += 0
			var -= 1
			lol += 1
if lol == e:
	print success


excuse the Names of some of my variables. (E.G. lol)

at first, the string split method is a … method. it means you have to make a proper call, with parenthesis.


next, why do you use floats ? the input data are said to be integers.

a, b = map(int, raw_input().split())

next, in your loop, number is never assigned, so Python does not know what is its value. you probably meant :

for i in xrange(a):

next, your loop ends, you read all the t_i values, but did nothing with them. you should consider doing the modulo test inside your for loop. as far as i can tell, you don’t need any extra variable, such as var, lol, and success. you need only one, to count the number of t_i that equals 0 modulo k.

maybe you should start by writing your algorithm in pseudo-code, and then translate it in Python after. it should be easier for you to implement it correctly. good luck :slight_smile:


You can discuss about the same problem here.