第一题
a+b模拟
第二题
单调队列维护
第三题
简单的完全背包+快速幂
第四题
...没探索出来
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
program abc;
var v:array[0..1000000]of longint;
a:array[0..1000000]of longint;
head,tail,max,i,j,n,w,min,ans1,ans2:longint;
begin
//assign(input,'input2.txt');reset(input);
readln(n,w);
for i:=1 to n do readln(a[i]);
head:=1;
tail:=1;
v[a[1]]:=1;
max:=1;
while tail<>n do
begin
inc(tail);
if v[a[tail]]=0 then inc(max);
inc(v[a[tail]]);
if (tail-head+1>w) then
begin
if v[a[head]]=1 then dec(max);
dec(v[a[head]]);
inc(head);
end;
while v[a[head]]>1 do
begin
dec(v[a[head]]);
inc(head);
end;
if max>ans1 then ans1:=max;
end;
head:=1;
tail:=1;
fillchar(v,sizeof(v),0);
v[a[1]]:=1;
min:=1;
ans2:=maxlongint;
while tail<>n do
begin
inc(tail);
if v[a[tail]]=0 then inc(min);
inc(v[a[tail]]);
if tail-head+1>w then
begin
if v[a[head]]=1 then dec(min);
dec(v[a[head]]);
inc(head);
end;
while v[a[head]]>1 do
begin
dec(v[a[head]]);
inc(head);
end;
if min=ans1 then
if tail-head+1<ans2 then ans2:=tail-head+1;
end;
writeln(ans1,' ',ans2);
end.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 const prime:array[1..168]of integer=(2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
2 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
3 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
4 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
5 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
6 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
7 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
8 353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
9 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
10 467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
11 547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
12 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
13 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
14 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
15 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
16 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
17 947, 953, 967, 971, 977, 983, 991, 997);
18 var f:array[0..1010]of int64;
19 i,j,v:longint;
20 ans:int64;
21 function power(i:int64):int64;
22 var k,l:int64;
23 begin
24 k:=2;l:=1;
25 while i>0 do
26 begin
27 if i and 1=1 then l:=l*k mod 2011;
28 i:=i shr 1;
29 k:=k*k mod 2011;
30 end;
31 exit(l);
32 end;
33 begin
34 //assign(input,'input3.txt');reset(input);
35 readln(v);
36 f[0]:=1;
37 for i:=1 to 168 do
38 begin
39 if prime[i]>v then break;
40 for j:=prime[i] to v do
41 begin
42 if (f[j-prime[i]]>0) then
43 inc(f[j],f[j-prime[i]]);
44 end;
45 end;
46 //writeln(f[v]);halt;
47 ans:=power(f[v]);
48 writeln(ans);
49 end.
50
51