# your code goes here# your code goes here
import random
def CalcNum(s):
num = 0
for i in range(len(items_num)) :
num += items_weight[s][i]*items_num[i]
return num;
items_weight = [[0,100,300,1500],[30,100,300,1500]]
items_num = [1,3,3,5]
cnt_items = [0]*12
num_sim = 30000
for i in range(num_sim):
items_num = [1,3,3,5]
#print(cnt_items)
flag=0
for j in range(12):
if j<5 :
s=0
else:
s=1
rand = random.randint(1,CalcNum(s))
for k in range(len(items_num)) :
if rand <= items_weight[s][k]*items_num[k] :
items_num[k]-=1
#print("No%d:%d"%(j, k))
if k==0 :
cnt_items[j] +=1
flag=1
break
else:
rand -= items_weight[s][k]*items_num[k]
if rand == 0:
print("error")
exit()
if flag == 1 :
break
print(cnt_items)
for i in range(12):
print("%d: %f"%(i+1, float(cnt_items[i])/num_sim*100))
IyB5b3VyIGNvZGUgZ29lcyBoZXJlIyB5b3VyIGNvZGUgZ29lcyBoZXJlCgppbXBvcnQgcmFuZG9tCgpkZWYgQ2FsY051bShzKToKCW51bSA9IDAKCWZvciBpIGluIHJhbmdlKGxlbihpdGVtc19udW0pKSA6CgkJbnVtICs9IGl0ZW1zX3dlaWdodFtzXVtpXSppdGVtc19udW1baV0KCXJldHVybiBudW07CgppdGVtc193ZWlnaHQgPSBbWzAsMTAwLDMwMCwxNTAwXSxbMzAsMTAwLDMwMCwxNTAwXV0KaXRlbXNfbnVtID0gWzEsMywzLDVdCmNudF9pdGVtcyA9IFswXSoxMgpudW1fc2ltID0gMzAwMDAKCmZvciBpIGluIHJhbmdlKG51bV9zaW0pOgoJaXRlbXNfbnVtID0gWzEsMywzLDVdCgkjcHJpbnQoY250X2l0ZW1zKQoJZmxhZz0wCglmb3IgaiBpbiByYW5nZSgxMik6CgkJaWYgajw1IDoKCQkJcz0wCgkJZWxzZToKCQkJcz0xCgkJcmFuZCA9IHJhbmRvbS5yYW5kaW50KDEsQ2FsY051bShzKSkKCQlmb3IgayBpbiByYW5nZShsZW4oaXRlbXNfbnVtKSkgOgoJCQlpZiByYW5kIDw9IGl0ZW1zX3dlaWdodFtzXVtrXSppdGVtc19udW1ba10gOgoJCQkJaXRlbXNfbnVtW2tdLT0xCgkJCQkjcHJpbnQoIk5vJWQ6JWQiJShqLCBrKSkKCQkJCWlmIGs9PTAgOgoJCQkJCWNudF9pdGVtc1tqXSArPTEKCQkJCQlmbGFnPTEKCQkJCWJyZWFrCgkJCWVsc2U6CgkJCQlyYW5kIC09IGl0ZW1zX3dlaWdodFtzXVtrXSppdGVtc19udW1ba10KICAgIAkJaWYgcmFuZCA9PSAwOgogICAgCQkJcHJpbnQoImVycm9yIikKICAgIAkJCWV4aXQoKQoJCWlmIGZsYWcgPT0gMSA6CgkJCWJyZWFrCnByaW50KGNudF9pdGVtcykKZm9yIGkgaW4gcmFuZ2UoMTIpOgoJcHJpbnQoIiVkOiAlZiIlKGkrMSwgZmxvYXQoY250X2l0ZW1zW2ldKS9udW1fc2ltKjEwMCkpCgkJCQk=
[0, 0, 0, 0, 0, 402, 738, 1028, 1669, 2758, 4929, 18476]
1: 0.000000
2: 0.000000
3: 0.000000
4: 0.000000
5: 0.000000
6: 1.340000
7: 2.460000
8: 3.426667
9: 5.563333
10: 9.193333
11: 16.430000
12: 61.586667