Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- f = open('auction.txt')
- s = f.read()
- f.close()
- def genereer(n,p1,w1,m,k,a,b,c,d):
- p = []
- w = []
- p.append(p1)
- w.append(w1)
- for i in xrange(1,n):
- p.append( ((a*p[i-1] + b) % m) + 1)
- w.append( ((c*w[i-1] + d) % k) + 1)
- return (p,w)
- def koopjes((products,weights)):
- totaal = 0
- for (p,w) in zip(products,weights):
- n = 0
- for (p1,w1) in zip(products,weights):
- if p1 < p and not w1 > w:
- n += 1
- if w1 < w and not p1 > p:
- n += 1
- if n == 0:
- totaal += 1
- return totaal
- def dure((products,weights)):
- totaal = 0
- for (p,w) in zip(products,weights):
- n = 0
- for (p1,w1) in zip(products,weights):
- if p < p1 and not w > w1:
- n += 1
- if w < w1 and not p > p1:
- n += 1
- if n == 0:
- totaal += 1
- return totaal
- print genereer(5,1,4,5,7,1,0,1,2)
- #print koopjes(genereer(5,1,4,5,7,1,0,1,2))
- #print dure(genereer(5,1,4,5,7,1,0,1,2))
- f = open('auction_out.txt', 'w')
- l = s.split('\n')
- for c in range(1,int(l[0])+1):
- s = l[c].split(' ')
- #n,p1,w1,m,k,a,b,c,d
- n = int(s[0])
- p1 = int(s[1])
- w1 = int(s[2])
- m = int(s[3])
- k = int(s[4])
- a = int(s[5])
- b = int(s[6])
- cc = int(s[7])
- d = int(s[8])
- g = genereer(n,p1,w1,m,k,a,b,cc,d)
- #print "Case #" + str(c) + ": " + str(dure(genereer(n,p1,w1,m,k,a,b,cc,d))) + " " + str(koopjes(genereer(n,p1,w1,m,k,a,b,cc,d)))
- f.write("Case #" + str(c) + ": " + str(dure(g)) + " " + str(koopjes(g)) + '\n')
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment