SDUT OJ 陣列計算機(線段樹)

2022-08-30 05:42:14 字數 922 閱讀 3820

time limit: 1000 ms memory limit: 65536 kib

submit

statistic

problem description

blue 有乙個神器的機器,這個機器可以讀入乙個陣列,並按照使用者要求快速地進行陣列的處理和計算,它支援如下兩種操作:

這個機器就是這麼的神奇,但是 blue 的計算機壞掉了,你能幫他修一下嗎?

input

輸入資料有多組(資料組數不超過 20),到 eof 結束。

對於每組資料:

output

對於每組資料中的每次型別為 2 的操作,輸出 1 行,包含乙個整數,表示計算出的和。

sample input

5

1 2 3 4 5

52 1 2

2 1 5

1 4 10

2 4 5

2 1 5

sample output

3

1519

25

補一波學長的總結:

#include#include#includeusing namespace std;

struct node

;struct node tree[1234567];

long long int begin[1234567];

void buildtree( int root, int l, int r )

}long long int query ( int root, int l, int r )

void updata ( int root, long long int pos, long long int data )

int main()

}return 0;

}

陣列計算機

陣列計算機 time limit 1000ms memory limit 65536kb submit statistic discuss problem description blue 有乙個神器的機器,這個機器可以讀入乙個陣列,並按照使用者要求快速地進行陣列的處理和計算,它支援如下兩種操作 操...

樹狀陣列 陣列計算機

陣列計算機 time limit 1000ms memory limit 65536kb submit statistic problem description blue 有乙個神器的機器,這個機器可以讀入乙個陣列,並按照使用者要求快速地進行陣列的處理和計算,它支援如下兩種操作 操作 1 把陣列中...

計算機 計算機基礎整理

大學四年浪費的代價。半夜整理東西 cpu 其功能主要是解釋計算機指令以及處理計算機軟體中的資料。cpu由運算器 控制器和暫存器及實現它們之間聯絡的資料 控制及狀態的匯流排構成。差不多所有的cpu的運作原理可分為四個階段 提取 fetch 解碼 decode 執行 execute 和寫回 writeb...