fork(10) download
  1. import itertools
  2.  
  3. def add_dice(die1, die2):
  4. die3 = [0]*(len(die1) + len(die2) - 1)
  5. for i, prob1 in enumerate(die1):
  6. for j, prob2 in enumerate(die2):
  7. die3[i+j] += prob1*prob2
  8. return die3
  9.  
  10. def cumsum(die):
  11. return list(itertools.accumulate(die))
  12.  
  13. def one_5_star():
  14. die = [0]*91
  15. prob = 0.006
  16. reach_prob = 1.0
  17. for i in range(1, 91):
  18. if i >= 74:
  19. prob += 0.06
  20. if prob > 1.0:
  21. prob = 1.0
  22. die[i] = reach_prob * prob
  23. reach_prob *= 1.0 - prob
  24. return die
  25.  
  26. def one_banner_5_star():
  27. base = one_5_star()
  28. die2 = base[:]
  29. die2[0] = 0.5
  30. for i in range(1, 91):
  31. die2[i] *= 0.5
  32. return add_dice(base, die2)
  33.  
  34. anyone = one_5_star()
  35.  
  36. banner = one_banner_5_star()
  37.  
  38. two_banner = add_dice(banner, banner)
  39.  
  40. print('anyone')
  41. for i, prob in enumerate(cumsum(anyone)):
  42. print(i, prob)
  43. print()
  44.  
  45. print('banner')
  46. for i, prob in enumerate(cumsum(banner)):
  47. print(i, prob)
  48. print()
  49.  
  50. print('two banner')
  51. for i, prob in enumerate(cumsum(two_banner)):
  52. print(i, prob)
  53. print()
Success #stdin #stdout 0.03s 9292KB
stdin
Standard input is empty
stdout
anyone
0 0
1 0.006
2 0.011963999999999999
3 0.017892216
4 0.023784862704
5 0.029642153527776
6 0.03546430060660934
7 0.04125151480296969
8 0.04700400571415187
9 0.05272198167986696
10 0.05840564978978776
11 0.06405521589104904
12 0.06967088459570274
13 0.07525285928812853
14 0.08080134213239976
15 0.08631653407960535
16 0.09179863487512771
17 0.09724784306587694
18 0.10266435600748168
19 0.10804836987143679
20 0.11340007965220816
21 0.1187196791742949
22 0.12400736109924913
23 0.12926331693265364
24 0.1344877370310577
25 0.13968081060887136
26 0.14484272574521814
27 0.14997366939074683
28 0.15507382737440234
29 0.16014338441015594
30 0.165182524103695
31 0.17019142895907283
32 0.1751702803853184
33 0.1801192587030065
34 0.18503854315078844
35 0.1899283118918837
36 0.1947887420205324
37 0.1996200095684092
38 0.20442228951099875
39 0.20919575577393276
40 0.21394058123928916
41 0.21865693775185344
42 0.2233449961253423
43 0.22800492614859025
44 0.2326368965916987
45 0.23724107521214852
46 0.24181762876087562
47 0.24636672298831036
48 0.2508885226503805
49 0.2553831915144782
50 0.25985089236539133
51 0.264291787011199
52 0.2687060362891318
53 0.273093800071397
54 0.2774552372709686
55 0.2817905058473428
56 0.28609976281225874
57 0.2903831642353852
58 0.29464086524997285
59 0.298873020058473
60 0.30307978193812213
61 0.30726130324649337
62 0.3114177354270144
63 0.3155492290144523
64 0.3196559336403656
65 0.3237379980385234
66 0.32779557005029225
67 0.3318287966299905
68 0.33583782385021055
69 0.33982279690710926
70 0.3437838601256666
71 0.34772115696491257
72 0.35163483002312307
73 0.35552502104298433
74 0.3980603696541474
75 0.4739047630777248
76 0.5717584771452678
77 0.6771058917675319
78 0.7759114888866671
79 0.8579278839541468
80 0.91845060538968
81 0.9580836111702953
82 0.9809699594713138
83 0.9925021640316973
84 0.9974957227865866
85 0.9993138280435244
86 0.9998531592013139
87 0.999977386517002
88 0.9999978743325978
89 0.999999927727308
90 1.0000000018790896

banner
0 0.0
1 0.003
2 0.006
3 0.008999892
4 0.011999569296
5 0.014998926468336001
6 0.017997859370109313
7 0.020996265115708485
8 0.023994042069423144
9 0.02699108983414906
10 0.02998730924018377
11 0.03298260233411203
12 0.03597687236778051
13 0.03897002378736093
14 0.041961962222501155
15 0.044952594475563344
16 0.04794182851094878
17 0.05092957344450847
18 0.05391573953303905
19 0.05690023816386326
20 0.05988298184449439
21 0.06286388419238405
22 0.06584285992475263
23 0.06881982484850185
24 0.0717946958502088
25 0.07476739088620071
26 0.07773782897271012
27 0.08070593017610951
28 0.0836716156032251
29 0.08663480739172896
30 0.08959542870060906
31 0.09255340370071649
32 0.09550865756538941
33 0.09846111646115303
34 0.10141070753849514
35 0.10435735892271654
36 0.10730099970485589
37 0.11024155993268835
38 0.11317897060179745
39 0.11611316364671966
40 0.11904407193216114
41 0.12197162924428605
42 0.1248957702820759
43 0.12781643064875947
44 0.13073354684331268
45 0.13364705625202788
46 0.13655689714015215
47 0.13946300864359387
48 0.14236533076069724
49 0.1452638043440842
50 0.14815837109256313
51 0.15104897354310393
52 0.1539355550628789
53 0.156818059841369
54 0.159696432882535
55 0.1625706199970527
56 0.16544056779461241
57 0.1683062236762815
58 0.17116753582692998
59 0.1740244532077183
60 0.17687692554864742
61 0.17972490334116992
62 0.18256833783086238
63 0.18540718101015824
64 0.18824138561114065
65 0.1910709050983949
66 0.19389569366192008
67 0.19671570621009943
68 0.1995308983627288
69 0.20234122644410307
70 0.2051466474761598
71 0.20794711917167982
72 0.2107425999275445
73 0.2135330488180486
74 0.23565267495697972
75 0.2746653233331637
76 0.3251196247355621
77 0.3798872722728689
78 0.4319921389149061
79 0.47626770107319444
80 0.5102576639138188
81 0.5341323444986179
82 0.5498360233027586
83 0.5599633300211456
84 0.566853350891862
85 0.5721483239051895
86 0.5767776455042647
87 0.5811657009040475
88 0.5854659486921338
89 0.5897206989637467
90 0.5939383503624336
91 0.5981201238092013
92 0.6022663341940963
93 0.6063772577300168
94 0.6104531685955769
95 0.6144943389495734
96 0.6185010389453539
97 0.6224735367450844
98 0.6264120985339175
99 0.6303169885340634
100 0.6341884690187617
101 0.6380268003261579
102 0.6418322408730821
103 0.6456050471687329
104 0.649345473828266
105 0.6530537735862881
106 0.6567301973102576
107 0.6603749940137918
108 0.6639884108698819
109 0.6675706932240159
110 0.6711220846072103
111 0.6746428267489519
112 0.6781331595900483
113 0.68159332129539
114 0.6850235482666237
115 0.6884240751547375
116 0.6917951348725578
117 0.6951369586071602
118 0.6984497758321934
119 0.7017338143201178
120 0.7049893001543587
121 0.7082164577413745
122 0.7114155098226421
123 0.7145866774865574
124 0.7177301801802535
125 0.7208462357213371
126 0.7239350603095428
127 0.7269968685383055
128 0.7300318734062533
129 0.7330402863286198
130 0.7360223171485769
131 0.7389781741484881
132 0.7419080640610844
133 0.7448121920805618
134 0.7476907618736007
135 0.7505439755903097
136 0.7533720338750922
137 0.7561751358774376
138 0.7589534792626367
139 0.7617072602224233
140 0.7644366734855406
141 0.7671419123282338
142 0.7698231685846708
143 0.7724806326572882
144 0.7751144935270665
145 0.7777249387637334
146 0.7803121545358948
147 0.7828763256210961
148 0.7861652618131162
149 0.791468053046232
150 0.80019235844953
151 0.8133634026968474
152 0.8312225414989302
153 0.8530699292442459
154 0.877401236877117
155 0.9022756395838246
156 0.9257732070774782
157 0.9463866096765923
158 0.9632415048307159
159 0.9761195502933497
160 0.9853278375321668
161 0.9914932812253121
162 0.9953576442068829
163 0.9976224668123088
164 0.9988612930811338
165 0.9994920427985003
166 0.9997899583233264
167 0.9999199397800136
168 0.9999720568959146
169 0.9999911408506023
170 0.9999974741619618
171 0.9999993612624198
172 0.9999998602441467
173 0.9999999756016945
174 0.9999999984711938
175 1.0000000022586157
176 1.0000000027635711
177 1.0000000028148524
178 1.0000000028184797
179 1.000000002818632
180 1.0000000028186347

two banner
0 0.0
1 0.0
2 9e-06
3 2.7e-05
4 5.3999352e-05
5 8.9996767776e-05
6 0.00013499032659768
7 0.00018897748288803994
8 0.0002519550738252795
9 0.0003239193268871977
10 0.0004048658673383921
11 0.0004947897256605378
12 0.0005936853449260249
13 0.0007015465881152358
14 0.0008183667453777403
15 0.0009441385412376882
16 0.0010788541417436797
17 0.0012225051615633914
18 0.001375082671023237
19 0.0015365772030933424
20 0.0017069787603181115
21 0.0018862768216926645
22 0.002074460349485422
23 0.0022715177960071172
24 0.0024774371103265095
25 0.0026922057449330797
26 0.0029158106623469824
27 0.0031482383416765324
28 0.0033894747851234987
29 0.003639505524436488
30 0.0038983156273126847
31 0.00416588970374823
32 0.004442211912337509
33 0.004727265966521627
34 0.005021035140786336
35 0.005323502276809702
36 0.0056346497895597685
37 0.0059544596733425055
38 0.006282913507800298
39 0.00661999246386126
40 0.006965677309639641
41 0.007319948416287589
42 0.007682785763798547
43 0.00805416894676255
44 0.008434077180073695
45 0.008822489304590038
46 0.009219383792746207
47 0.009624738754118982
48 0.010038531940946116
49 0.010460740753598655
50 0.010891342246007036
51 0.01133031313104121
52 0.011777629785845074
53 0.01223326825712545
54 0.012697204266395904
55 0.013169413215175644
56 0.013649870190143762
57 0.014138549968249089
58 0.014635427021775919
59 0.015140475523365862
60 0.015653669350996074
61 0.01617498209291415
62 0.01670438705252989
63 0.01724185725326426
64 0.017787365443355723
65 0.018340884100624285
66 0.018902385437193425
67 0.019471841404170232
68 0.020049223696283945
69 0.020634503756483194
70 0.021227652780492167
71 0.021828641721325957
72 0.022437441293765344
73 0.023054021978791268
74 0.023678354027979208
75 0.02442641296406603
76 0.025399557396529972
77 0.02666643356052314
78 0.028252910091236635
79 0.030142988724349916
80 0.03228966110649772
81 0.03463117087454063
82 0.03710677514156113
83 0.03966739060111402
84 0.04227949788194109
85 0.04492361009976493
86 0.047590092998281125
87 0.05027488861041539
88 0.05297648553826985
89 0.05569429353575647
90 0.058427976666651726
91 0.06117724985114242
92 0.0639418358054048
93 0.06672145960942803
94 0.0695158484786286
95 0.07232473175518946
96 0.07514784089936352
97 0.07798490948074267
98 0.08083567316949347
99 0.08369986972756092
100 0.0865772389998413
101 0.08946752290532531
102 0.09237046542821281
103 0.09528581260899999
104 0.09821331253554036
105 0.10115271533408063
106 0.1041037731602724
107 0.10706624019016096
108 0.11003987261115208
109 0.11302442861295789
110 0.11601966837852297
111 0.11902535407493153
112 0.12204124984429673
113 0.12506712179463314
114 0.12810273799071328
115 0.1311478684449093
116 0.13420228510802046
117 0.1372657618600877
118 0.14033807450119606
119 0.14341900074226566
120 0.14650832019583243
121 0.14960581436681933
122 0.15271126664329884
123 0.15582446228724772
124 0.15894518842529476
125 0.16207323403946236
126 0.1652083899579029
127 0.16835044884563033
128 0.17149920519524817
129 0.17465445531767448
130 0.17781599733286457
131 0.1809836311605323
132 0.18415715851087036
133 0.18733638287527096
134 0.19052110951704682
135 0.1937111454621537
136 0.196906299489915
137 0.20010638212374907
138 0.20331120562189994
139 0.2065205839681722
140 0.2097343328626704
141 0.21295226971254413
142 0.2161742136227387
143 0.21939998538675265
144 0.22262940747740242
145 0.22586230403759477
146 0.22909850087110756
147 0.23233782543337947
148 0.2359539200209608
149 0.24060452659464637
150 0.24702987435973478
151 0.25580431171248713
152 0.2671287038624634
153 0.2807376548116545
154 0.2959509218320387
155 0.31184292564683824
156 0.3274635861788827
157 0.3420345502258657
158 0.35506681134433415
159 0.3663836112617763
160 0.37606696660914646
161 0.38436432404069343
162 0.3915918322005185
163 0.3980588761073986
164 0.4040234682612495
165 0.40967613223602745
166 0.41514357589020484
167 0.4205022914179589
168 0.42579432547814383
169 0.4310407283594656
170 0.43625108470826396
171 0.44142935696001234
172 0.4465770355964006
173 0.4516946410595297
174 0.45678235687865215
175 0.4618402646141111
176 0.4668684199700676
177 0.47186687404550454
178 0.4768356783452401
179 0.4817748857375989
180 0.48668455057956483
181 0.4915647287064082
182 0.49641547740502184
183 0.5012368553862117
184 0.5060289227572637
185 0.5107917409948494
186 0.5155253729182665
187 0.5202298826630137
188 0.5249053356546929
189 0.5295517985832381
190 0.5341693393774664
191 0.5387580271799474
192 0.543317932322189
193 0.5478491263001345
194 0.5523516817499696
195 0.5568256724242348
196 0.5612711731682395
197 0.5656882598967774
198 0.5700770095711362
199 0.5744375001764012
200 0.578769810699049
201 0.5830740211048282
202 0.5873502123169233
203 0.5915984661944006
204 0.5958188655109311
205 0.6000114939337887
206 0.604176436003121
207 0.608313777111488
208 0.612423603483669
209 0.6165060021567307
210 0.6205610609603583
211 0.6245888684974429
212 0.6285895141249244
213 0.6325630879348871
214 0.6365096807359052
215 0.6404293840346343
216 0.6443222900176488
217 0.6481884915335198
218 0.6520280820751325
219 0.6558411557622407
220 0.6596278073242546
221 0.663388132083261
222 0.6671511355276712
223 0.6710209308211567
224 0.6752167328918991
225 0.6800809267328081
226 0.6860392474684937
227 0.6935155866886584
228 0.7028233547315169
229 0.714067027081633
230 0.7270862122415522
231 0.7414609356739066
232 0.7565768229220607
233 0.7717306442503714
234 0.7862467369983984
235 0.7995754696113896
236 0.8113541347789511
237 0.8214238061233067
238 0.8298078256133721
239 0.8366653167608936
240 0.8422353461991643
241 0.8467849972088788
242 0.850569699967116
243 0.8538088284544011
244 0.8566753707666387
245 0.8592960874382883
246 0.8617579122969072
247 0.8641168988225016
248 0.866407135879667
249 0.8686482324210312
250 0.8708508982980888
251 0.8730207277498634
252 0.8751605597107263
253 0.8772718416035762
254 0.8793553616940561
255 0.8814116151389623
256 0.8834409743090129
257 0.8854437625051423
258 0.8874202835881781
259 0.8893708330174499
260 0.8912957016576393
261 0.8931951769979157
262 0.8950695435225124
263 0.8969190828274852
264 0.8987440736685591
265 0.9005447919920208
266 0.9023215109617543
267 0.9040745009853556
268 0.9058040297399036
269 0.9075103621974882
270 0.9091937606505112
271 0.9108544847367637
272 0.9124927914642812
273 0.9141089352359802
274 0.9157031678740759
275 0.9172757386442842
276 0.9188268942798101
277 0.9203568790051226
278 0.9218659345595205
279 0.9233543002204878
280 0.9248222128268437
281 0.9262699068016861
282 0.9276976141751321
283 0.9291055646068568
284 0.9304939854084318
285 0.9318631015654654
286 0.9332131357595462
287 0.9345443083899916
288 0.9358568375954026
289 0.9371509392750277
290 0.9384268271099355
291 0.9396847125840002
292 0.940924805004699
293 0.9421473115237249
294 0.9433524371574157
295 0.9445403848070005
296 0.945711914223896
297 0.9468702692727462
298 0.9480249437708381
299 0.9491968424298269
300 0.9504232648705607
301 0.9517603661023774
302 0.9532808320222671
303 0.9550656227184078
304 0.9571904858546064
305 0.9597098670636521
306 0.9626420963823459
307 0.9659597973934697
308 0.9695882855076895
309 0.9734126899529024
310 0.9772923281455619
311 0.9810791685131109
312 0.9846364926368208
313 0.9878542067634871
314 0.9906584178029729
315 0.9930144387009326
316 0.9949238533946398
317 0.996417302470798
318 0.9975450924216089
319 0.998367621568439
320 0.9989471236096459
321 0.9993415735807126
322 0.9996009750063811
323 0.9997657776728387
324 0.9998669108310809
325 0.999926840866331
326 0.999961122329546
327 0.9999800430628633
328 0.9999901132469659
329 0.9999952782534528
330 0.9999978292294461
331 0.9999990414036788
332 0.9999995950328003
333 0.999999837798941
334 0.9999999398781497
335 0.9999999809809486
336 0.999999996805458
337 1.000000002620892
338 1.0000000046570696
339 1.0000000053349147
340 1.0000000055489695
341 1.0000000056129257
342 1.000000005630954
343 1.0000000056357328
344 1.0000000056369196
345 1.0000000056371947
346 1.000000005637254
347 1.0000000056372658
348 1.000000005637268
349 1.0000000056372684
350 1.0000000056372684
351 1.0000000056372684
352 1.0000000056372684
353 1.0000000056372684
354 1.0000000056372684
355 1.0000000056372684
356 1.0000000056372684
357 1.0000000056372684
358 1.0000000056372684
359 1.0000000056372684
360 1.0000000056372684