Skip to content

Instantly share code, notes, and snippets.

@LXZE
Created April 12, 2015 06:22
Show Gist options
  • Save LXZE/990820a7bf0da073e1a0 to your computer and use it in GitHub Desktop.
Save LXZE/990820a7bf0da073e1a0 to your computer and use it in GitHub Desktop.
import re
f = open("A-large.in","r")
w = open("output_aLarge.txt","w")
num = f.readline()
for i in range(0,int(num)):
res = 0
smax,aud = [str(l) for l in f.readline().split()]
clap = int(aud[0])
for j,nSi in enumerate([int(x) for x in aud]):
if j == 0:
continue
else:
if nSi > 0:
if clap < j:
invite = j-clap
res+=invite
clap+=nSi+invite
else:
clap+=nSi
print("Case #{0}: {1} ".format(i+1,res))
w.write("Case #{0}: {1}\n".format(i+1,res))
w.close()
import re
import math
f = open("d_icez.txt","r")
w = open("output_dicez.txt","w")
num = f.readline()
for i in range(0,int(num)):
ans = ['GABRIEL','RICHARD']
res = ''
x,r,c = [int(l) for l in f.readline().split()]
allpos = []
for i1 in range(x,int(math.ceil((x/2.0)))-1,-1):
d1 = i1
if x-i1 == 0: allpos.append([d1,1])
elif x-i1 == 1: allpos.append([d1,2])
else:
d2 = 2
while d2+d1<=x+1:
allpos.append([d1,d2])
d2+=1
allpos = sorted([sorted(d,reverse=True) for d in allpos],reverse=True)
minedge = min([r,c])
maxedge = max([r,c])
found = False
for pos in allpos:
if x == r and x == c : break
else:
if minedge*maxedge % pos[0]*pos[1] != 0:
found = True
res = ans[0] if not found else ans[1]
print("Case #{0}: {1} ".format(i+1,res))
w.write("Case #{0}: {1}\n".format(i+1,res))
w.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment