Skip to content

Instantly share code, notes, and snippets.

@okaq
Created May 21, 2011 16:46
Show Gist options
  • Save okaq/984676 to your computer and use it in GitHub Desktop.
Save okaq/984676 to your computer and use it in GitHub Desktop.
Solution: FreeCell Statistics(Google Code Jam 2011 Round 1A Problem A)
import sys
import math
# files
fin = file(sys.argv[1])
fout = open(sys.argv[2], 'w')
lines = fin.readlines()
tests = int(lines[0])
def possible(pg, pd):
if ((pg == pd) and (pg == 0 or pg == 100)):
return True
if ((pg != pd) and (pg != 100 and pg != 0)):
return True
return False
for i in range (1, tests+1):
[n,pd,pg] = map(int, lines[i].split())
j = 1
p = False
while j < n+1:
d = j * float(pd) / 100.0
if math.modf(d)[0] == 0:
if possible(pg, pd):
p = True
fout.write("Case #%d: Possible\n" % i)
break
if j >= 100:
if possible(pg, pd):
p = True
fout.write("Case #%d: Possible\n" % i)
break
break
j += 1
if not p:
fout.write("Case #%d: Broken\n" % i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment