← Back to Problems
The Implied Distribution
Medium standard Pricing
Time limit: 2 s per test  ·  Memory: 256 MB

Under the risk-neutral measure, the stock price at expiry T has some distribution with a smooth density on (0, infinity). The distribution is not disclosed. The continuously compounded rate is r.

You observe the prices C_1, ..., C_m of European calls with strikes K_1 < K_2 < ... < K_m (equally spaced), all expiring at T, priced under this distribution and then rounded to 8 decimal places.

Compute P(S_T > x_j) for each of the three query levels x_1, x_2, x_3. All query levels lie strictly inside the strike range.

Input

The first line contains r, T and m. The next m lines each contain K_j and C_j. The last line contains x_1, x_2 and x_3.

Output

Three real numbers on one line: P(S_T > x_1), P(S_T > x_2), P(S_T > x_3), each within 1e-4 of the true value.

Constraints

40 <= m <= 80

-0.03 <= r <= 0.08, 0.05 <= T <= 5

Every answer lies in [0.02, 0.98]

The prices are exact up to the disclosed rounding (8 decimal places)

Scoring

This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.

Numeric answers are accepted if they are within an absolute tolerance of 0.0001 or a relative tolerance of 0.0001 of the expected value.

Examples

input
0.033487 4.84095 69
39.9713 29.79087459
41.546 28.47617808
43.1207 27.17178853
44.6955 25.88061261
46.2702 24.60616756
47.845 23.35191958
49.4197 22.12181528
50.9945 20.91951562
52.5692 19.74888562
54.144 18.61325661
55.7187 17.51590710
57.2934 16.45946152
58.8682 15.44605290
60.4429 14.47746629
62.0177 13.55468343
63.5924 12.67838620
65.1672 11.84851915
66.7419 11.06478083
68.3167 10.32625846
69.8914 9.63188855
71.4661 8.98018554
73.0409 8.36945747
74.6156 7.79796916
76.1904 7.26373046
77.7651 6.76483418
79.3399 6.29922415
80.9146 5.86498221
82.4894 5.46011739
84.0641 5.08280717
85.6388 4.73122743
87.2136 4.40364684
88.7883 4.09848788
90.3631 3.81418745
91.9378 3.54935263
93.5126 3.30261413
95.0873 3.07275806
96.662 2.85860933
98.2368 2.65907842
99.8115 2.47318985
101.3863 2.29999053
102.961 2.13863938
104.5358 1.98831412
106.1105 1.84828881
107.6853 1.71785287
109.26 1.59637829
110.8347 1.48325639
112.4095 1.37792155
113.9842 1.27986578
115.559 1.18859016
117.1337 1.10365220
118.7085 1.02461698
120.2832 0.95109828
121.858 0.88271634
123.4327 0.81913358
125.0074 0.76002171
126.5822 0.70507458
128.1569 0.65401599
129.7317 0.60657462
131.3064 0.56250886
132.8812 0.52158158
134.4559 0.48358159
136.0306 0.44830395
137.6054 0.41555772
139.1801 0.38517060
140.7549 0.35697392
142.3296 0.33081747
143.9044 0.30655438
145.4791 0.28405387
147.0539 0.26318826
111.2599 121.4327 125.653
output
0.0799459921 0.0502082481 0.0412945523
input
0.011816 1.914023 62
19.8726 15.57751003
20.8256 14.66575054
21.7785 13.77054117
22.7314 12.89967655
23.6843 12.06183524
24.6373 11.26538485
25.5902 10.51765023
26.5431 9.82355452
27.496 9.18547975
28.4489 8.60313314
29.4019 8.07382080
30.3548 7.59323909
31.3077 7.15581888
32.2606 6.75560468
33.2135 6.38673736
34.1665 6.04380883
35.1194 5.72223767
36.0723 5.41815438
37.0252 5.12854631
37.9782 4.85112384
38.9311 4.58433053
39.884 4.32704985
40.8369 4.07860574
41.7898 3.83862708
42.7428 3.60693367
43.6957 3.38355917
44.6486 3.16854767
45.6015 2.96200809
46.5544 2.76405758
47.5074 2.57477953
48.4603 2.39428708
49.4132 2.22259458
50.3661 2.05969289
51.319 1.90552735
52.272 1.75998343
53.2249 1.62294920
54.1778 1.49422705
55.1307 1.37359987
56.0837 1.26080841
57.0366 1.15560262
57.9895 1.05767544
58.9424 0.96671557
59.8953 0.88239975
60.8483 0.80438895
61.8012 0.73236428
62.7541 0.66598134
63.707 0.60490658
64.6599 0.54881145
65.6129 0.49736946
66.5658 0.45027915
67.5187 0.40723327
68.4716 0.36794202
69.4246 0.33212478
70.3775 0.29952534
71.3304 0.26988987
72.2833 0.24298246
73.2362 0.21858119
74.1892 0.19647582
75.1421 0.17647659
76.095 0.15839992
77.0479 0.14207752
78.0008 0.12735344
49.6705 39.6268 39.3218
output
0.1770287532 0.2739140822 0.2770257455
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2