4
1701 1702 1703 1704
标签:
1 /************************************************************** 2 Problem: 1996 3 User: HansBug 4 Language: Pascal 5 Result: Accepted 6 Time:108 ms 7 Memory:8172 kb 8 ****************************************************************/ 9 10 const p=19650827; 11 var 12 i,j,k,l,m,n:longint; 13 c:array[0..10000] of longint; 14 a:array[0..1005,0..1005,1..2] of longint; 15 begin 16 readln(n); 17 for i:=1 to n do 18 begin 19 read(c[i]); 20 a[i,i,0]:=1; 21 end; 22 readln; 23 for i:=n-1 downto 1 do 24 for j:=i+1 to n do 25 begin 26 a[i,j,0]:=0;a[i,j,1]:=0; 27 if c[i]<c[i+1] then inc(a[i,j,0],a[i+1,j,0]); 28 if c[i]<c[j] then inc(a[i,j,0],a[i+1,j,1]); 29 if c[j]>c[i] then inc(a[i,j,1],a[i,j-1,0]); 30 if c[j]>c[j-1] then inc(a[i,j,1],a[i,j-1,1]); 31 a[i,j,0]:=a[i,j,0] mod p; 32 a[i,j,1]:=a[i,j,1] mod p; 33 end; 34 writeln((a[1,n,1]+a[1,n,0]) mod p); 35 readln; 36 end.
标签:
原文地址:http://www.cnblogs.com/HansBug/p/4471176.html