#K80267. Branch Growth Queries

    ID: 35493 Type: Default 1000ms 256MiB

Branch Growth Queries

Branch Growth Queries

In this problem, you are given the initial number of branches of a company and a series of queries about its exponential growth. The number of branches in year (Y) is calculated by the formula:

branches(Y)=initial_branches×2Y1branches(Y)=initial\_branches \times 2^{Y-1}

There are two types of queries:

  1. Query type 1: Given a year (Y), compute the number of branches in that year.
  2. Query type 2: Given a range of years ([L, R]), compute the total number of branches from year (L) to year (R) (inclusive), which is given by:
$$total=\sum_{y=L}^{R} initial\_branches \times 2^{y-1} $$

Your task is to process the queries and output the result for each query. Input is provided via standard input and the output should be printed to standard output.

inputFormat

The first line of input contains two integers: (initial_branches) and (q) (the number of queries). Each of the following (q) lines represents a query. For a query of type 1, the line is formatted as "1 Y". For a query of type 2, the line is formatted as "2 L R".

outputFormat

For each query, print the result on a separate line.## sample

5 5
1 3
2 1 3
1 5
2 2 4
1 7
20

35 80 70 320

</p>