• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Mar 31st, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. program solve;
2. {\$O-}
3. type tlong = array[0..100] of byte;
4. var
5.   syms: array[1..500] of byte;
6.   matr: array[0..320, 0..320] of tlong;
7.   len, k, i, j, i2: longint;
8.   st1: string;
9.
11. var i: byte;
12. begin
13.   for i := 1 to b do
14.     begin
15.       inc(k);
16.       syms[k] := a;
17.     end;
18. end;
19.
20. procedure addlong(var a, b: tlong);
21. var i, per, n: integer;
22. begin
23.   if (a[0] = 0) and (b[0] = 0) then exit;
24.   a[0] := 1;
25.   per := 0;
26.   for i := 1 to 100 do
27.     begin
28.       n := a[i] + b[i] + per;
29.       a[i] := n mod 10;
30.       per := n div 10;
31.     end;
32. end;
33.
34. procedure writelong(var a: tlong);
35. var i: integer;
36.   fl: boolean;
37. begin
38.   if (a[0] = 0) then
39.     begin
40.       write(0);
41.       exit;
42.     end;
43.   fl := false;
44.   for i := 100 downto 1 do
45.     begin
46.       if a[i] <> 0 then fl := true;
47.       if fl then write(a[i]);
48.     end;
49. end;
50.
51. begin
52.   assign(input, 'input.txt');
53.   reset(input);
54.   assign(output, 'output.txt');
55.   rewrite(output);
58.   k := 0;
59.   for i := 1 to length(st1) do
60.     begin
61.       case st1[i] of
88.       end;
89.     end;
90.   matr[0, 0][1] := 1;
91.   matr[0, 0][0] := 1;
92.   for i := 1 to k do
93.     begin
94.       if syms[i] in [1..5,7] then
95.         begin
96.           for j := 1 to 3 do
97.             if (i - j >= 0) and (syms[i - j + 1] = syms[i]) then
98.               begin
99.                 for i2 := 0 to 320 do if matr[i - j, i2][0] = 1 then break;
100.                 while (i2 <= 320) and (matr[i - j, i2][0] = 1) do
101.                   begin
102.                     addlong(matr[i, i2 + 1], matr[i - j, i2]);
103.                     inc(i2);
104.                   end;
105.               end else break;
106.         end else
107.         begin
108.           for j := 1 to 4 do
109.             if (i - j >= 0) and (syms[i - j + 1] = syms[i]) then
110.               begin
111.                 for i2 := 0 to 320 do if matr[i - j, i2][0] = 1 then break;
112.                 while (i2 <= 320) and (matr[i - j, i2][0] = 1) do
113.                   begin
114.                     addlong(matr[i, i2 + 1], matr[i - j, i2]);
115.                     inc(i2);
116.                   end;
117.               end else break;
118.         end;
119.     end;
120.   writelong(matr[k, len]);
121.   close(input);
122.   close(output);
123. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top