Created
May 21, 2011 16:46
-
-
Save okaq/984676 to your computer and use it in GitHub Desktop.
Solution: FreeCell Statistics(Google Code Jam 2011 Round 1A Problem A)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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