# bzoj1798: [Ahoi2009]Seq 维护序列seq 2011-12-20

1798: [Ahoi2009]Seq 维护序列seq

Time Limit: 30 Sec  Memory Limit: 64 MB

Submit: 497  Solved: 203

[Submit][Status][Discuss]

Description

Input

Output

Sample Input

7 43

1 2 3 4 5 6 7

5

1 2 5 5

3 2 4

2 3 7 9

3 1 3

3 4 7

Sample Output

2

35

8

HINT

【样例说明】

N=10100010001000060000700008000090000100000100000

M=10100010001000060000700008000090000100000100000

Source

Day1

_____________________________________

_____________________________________

  1 Program Stone;
2
3 var t,lc,rc,m:longint;
4
5     a:array[1..100000]of int64;
6
8
10
12
14
15   begin
16
18
19   end;
20
22
23   begin
24
25    if ti[num]<>1 then begin
26
27                        s[num]:=(s[num]*ti[num])mod q;
28
29                        ti[num*2]:=(ti[num*2]*ti[num])mod q;
30
32
33                        ti[num*2+1]:=(ti[num*2+1]*ti[num])mod q;
34
36
37                        ti[num]:=1;          //改变乘数。
38
39                      end;
40
42
44
46
48
50
51                      end;
52
53   end;
54
55
56
58
59  var k:longint;
60
61   begin
62
64
65       begin
66
67         ti[num]:=(ti[num]*tagtime)mod q;       //修改该区间乘数
68
70
71         exit;
72
73       end;
74
76
78
80
81    if k<rc  then update(k+1,tail,num*2+1);
82
84
85   end;
86
87
88
89
90
92
93  var k:longint;
94
95   begin
96
98
99       begin
100
102
103         exit;
104
105       end;
106
108
110
112
113    if k<rc  then query(k+1,tail,num*2+1);
114
116
117   end;
118
119
120
122
123  var i,j,k:longint;
124
125   begin
126
128
130
131                 else begin
132
134
136
137                       built(k+1,tail,num*2+1);
138
139                       s[num]:=(s[num*2]+s[num*2+1])mod q;
140
141                      end;
142
143   end;
144
145  procedure init;
146
147  var i,j,k:longint;
148
149   begin
150
152
153     for i:=1 to n do read(a[i]);
154
155     built(1,n,1);
156
158
159     for i:=1 to m do
160
161      begin
162
164
165       if t=3 then begin
166
168
169                    ans:=0;
170
171                    query(1,n,1);
172
173                    writeln(ans);
174
175                   end;
176
177       if t=1 then begin
178
180
182
183                    update(1,n,1);
184
185                   end;
186
187       if t=2 then begin
188
190
191                    tagtime:=1;
192
193                    update(1,n,1);
194
195                   end;
196
197      end;
198
199   end;
200
201 Begin
202
203  assign(input,'input.in');reset(input);
204
205   init;
206
207  close(input);
208
209 end.

posted on 2016-03-02 20:03  Yesphet  阅读(135)  评论(0编辑  收藏  举报