Your code looks good to me, except it is too slow to even pass the visible
test. (getting TLE verdict instead of RE)
It might be the case that you submitted the code with python2?
I slightly improved your code using the approach suggested by analysis and
passed both visible and hidden test.
Check out the code below
*t = int(input())*
*for test in range(1, t + 1):*
* n, m, q = map(int, input().split())*
* p = set([int(e) for e in input().split()])*
* r = [int(e) for e in input().split()]*
* tmp = [sum([1 for page in range(i, n + 1, i) if page not in p]) for i in
range(1, n + 1)]*
* result = sum([tmp[reader - 1] for reader in r])*
* print("Case #{}: {}".format(test, result))*
Hi,
> I'm new to doing Google Kickstart challenges and I tried doing the first
> on the latest problem set (Book Reading). I did it in Python and the code
> outputs the correct answer on my local machine, however it throws a RE when
> I try to submit my answer.
>
> Here is the code:
>
> t = int(input())
> for test in range(1, t + 1):
> n, m, q = map(int, input().split())
>
> p = [int(e) for e in input().split()]
> r = [int(e) for e in input().split()]
>
> result = 0
> for reader in range(q):
> result += sum([1 for page in range(1, n + 1) if page % r[reader] == 0
> and page not in p])
>
> print("Case #{}: {}".format(test, result))
>
> Thanks for your help.
>
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/de68a956-63f5-4139-8de4-ee91bb74d5e9%40googlegroups.com.