CF712E.Memory and Casinos

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn casinos lined in a row. If Memory plays at casino ii , he has probability pip_{i} to win and move to the casino on the right ( i+1i+1 ) or exit the row (if i=ni=n ), and a probability 1pi1-p_{i} to lose and move to the casino on the left ( i1i-1 ) or also exit the row (if i=1i=1 ).

We say that Memory dominates on the interval i... ji...\ j if he completes a walk such that,

  • He starts on casino ii .
  • He never looses in casino ii .
  • He finishes his walk by winning in casino jj .

Note that Memory can still walk left of the 11 -st casino and right of the casino nn and that always finishes the process.

Now Memory has some requests, in one of the following forms:

  • 11 ii aa bb : Set .
  • 22 ll rr : Print the probability that Memory will dominate on the interval l... rl...\ r , i.e. compute the probability that Memory will first leave the segment l... rl...\ r after winning at casino rr , if she starts in casino ll .

It is guaranteed that at any moment of time pp is a non-decreasing sequence, i.e. pi<=pi+1p_{i}<=p_{i+1} for all ii from 11 to n1n-1 .

Please help Memory by answering all his requests!

输入格式

The first line of the input contains two integers nn and qq ( 1<=n,q<=1000001<=n,q<=100000 ), — number of casinos and number of requests respectively.

The next nn lines each contain integers aia_{i} and bib_{i} ( 1<=a_{i}<b_{i}<=10^{9} ) — is the probability pip_{i} of winning in casino ii .

The next qq lines each contain queries of one of the types specified above ( 1<=a<b<=10^{9} , 1<=i<=n1<=i<=n , 1<=l<=r<=n1<=l<=r<=n ).

It's guaranteed that there will be at least one query of type 22 , i.e. the output will be non-empty. Additionally, it is guaranteed that pp forms a non-decreasing sequence at all times.

输出格式

Print a real number for every request of type 22 — the probability that boy will "dominate" on that interval. Your answer will be considered correct if its absolute error does not exceed 10410^{-4} .

Namely: let's assume that one of your answers is aa , and the corresponding answer of the jury is bb . The checker program will consider your answer correct if ab<=104|a-b|<=10^{-4} .

输入输出样例

  • 输入#1

    3 13
    1 3
    1 2
    2 3
    2 1 1
    2 1 2
    2 1 3
    2 2 2
    2 2 3
    2 3 3
    1 2 2 3
    2 1 1
    2 1 2
    2 1 3
    2 2 2
    2 2 3
    2 3 3
    

    输出#1

    0.3333333333
    0.2000000000
    0.1666666667
    0.5000000000
    0.4000000000
    0.6666666667
    0.3333333333
    0.2500000000
    0.2222222222
    0.6666666667
    0.5714285714
    0.6666666667
    
首页