10268_ASimpleProblemwithIntegers

2022-5-16 18:16| 发布者: Hocassian| 查看: 67| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504713934799-Problem List-采集的数据-后羿采集器.html

Pro.ID

10268

Title

A Simple Problem with Integers

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10268

AC

37

Submit

113

Ratio

32.74%

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others)
  • 描述

    You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.

    输入

    The first line contains two numbers N and Q. 1 ≤ N, Q ≤ 100000.

    The second line contains N numbers, the initial values of A1, A2, ... , AN. -1000000000 ≤ Ai ≤ 1000000000.

    Each of the next Q lines represents an operation.

    "C a b c" means adding c to each of Aa, Aa+1, ... , Ab. -10000 ≤ c ≤ 10000.

    "Q a b" means querying the sum of Aa, Aa+1, ... , Ab.

    输出

    Description

    You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.

    Input

    The first line contains two numbers N and Q. 1 ≤ N, Q ≤ 100000.

    The second line contains N numbers, the initial values of A1, A2, ... , AN. -1000000000 ≤ Ai ≤ 1000000000.

    Each of the next Q lines represents an operation.

    "C a b c" means adding c to each of Aa, Aa+1, ... , Ab. -10000 ≤ c ≤ 10000.

    "Q a b" means querying the sum of Aa, Aa+1, ... , Ab.

    Output

    You need to answer all Q commands in order. One answer in a line.

    Sample Input

    10 5
    1 2 3 4 5 6 7 8 9 10
    Q 4 4
    Q 1 10
    Q 2 4
    C 3 6 3
    Q 2 4

    Sample Output

    4
    55
    9
    15

    Hint

    The sums may exceed the range of 32-bit integers.

    Source
    Author

    样例输入

    10 5
    1 2 3 4 5 6 7 8 9 10
    Q 4 4
    Q 1 10
    Q 2 4
    C 3 6 3
    Q 2 4

    样例输出

    4
    55
    9
    15

    提示

    The sums may exceed the range of 32-bit integers.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部