59
									
								
								Canon.Tests/SemanticTests/Tests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								Canon.Tests/SemanticTests/Tests.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
using Canon.Core.SemanticParser;
 | 
			
		||||
using Canon.Core.SyntaxNodes;
 | 
			
		||||
using Canon.Tests.Utils;
 | 
			
		||||
using Xunit.Abstractions;
 | 
			
		||||
 | 
			
		||||
namespace Canon.Tests.SemanticTests;
 | 
			
		||||
 | 
			
		||||
public class Tests(ITestOutputHelper helper)
 | 
			
		||||
{
 | 
			
		||||
    [Fact]
 | 
			
		||||
    public void Test()
 | 
			
		||||
    {
 | 
			
		||||
        const string program = """
 | 
			
		||||
                               program main;
 | 
			
		||||
 | 
			
		||||
                               var
 | 
			
		||||
                               x, y: array[0..0] of integer;
 | 
			
		||||
                               a, b: integer;
 | 
			
		||||
 | 
			
		||||
                               function exgcd(a, b: integer; var x, y: integer): integer;
 | 
			
		||||
                               var
 | 
			
		||||
                               t, r: integer;
 | 
			
		||||
                               begin
 | 
			
		||||
                               if b = 0 then
 | 
			
		||||
                               begin
 | 
			
		||||
                               x := 1;
 | 
			
		||||
                               y := 0;
 | 
			
		||||
                               exgcd := a;
 | 
			
		||||
                               end
 | 
			
		||||
                               else
 | 
			
		||||
                               begin
 | 
			
		||||
                               r := exgcd(b, a mod b, x, y);
 | 
			
		||||
                               t := x;
 | 
			
		||||
                               x := y;
 | 
			
		||||
                               y := (t - (a div b) * y);
 | 
			
		||||
                               exgcd := r;
 | 
			
		||||
                               end;
 | 
			
		||||
                               end;
 | 
			
		||||
 | 
			
		||||
                               begin
 | 
			
		||||
                               a := 7;
 | 
			
		||||
                               b := 15;
 | 
			
		||||
                               x[0] := 1;
 | 
			
		||||
                               y[0] := 1;
 | 
			
		||||
                               exgcd(a, b, x[0], y[0]);
 | 
			
		||||
                               x[0] := ((x[0] mod b) + b) mod b;
 | 
			
		||||
                               write(x[0]);
 | 
			
		||||
                               end.
 | 
			
		||||
                               """;
 | 
			
		||||
 | 
			
		||||
        ProgramStruct root = CompilerHelpers.Analyse(program);
 | 
			
		||||
        SyntaxTreeTraveller traveller = new();
 | 
			
		||||
 | 
			
		||||
        CodeGeneratorVisitor visitor = new();
 | 
			
		||||
        traveller.Travel(root, visitor);
 | 
			
		||||
 | 
			
		||||
        helper.WriteLine(visitor.Builder.Build());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								open_set/70_comment2.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								open_set/70_comment2.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
// skipher
 | 
			
		||||
// int main(){
 | 
			
		||||
program main;
 | 
			
		||||
begin
 | 
			
		||||
    { ret := 0;
 | 
			
		||||
      ret := 1;
 | 
			
		||||
      ret := 2;
 | 
			
		||||
    }
 | 
			
		||||
    write(3);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										13
									
								
								open_set/71_multiple_returns.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								open_set/71_multiple_returns.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
program main;
 | 
			
		||||
const
 | 
			
		||||
    AA = 4;
 | 
			
		||||
var
 | 
			
		||||
    a, b, c, d: integer;
 | 
			
		||||
begin
 | 
			
		||||
    b := 8;
 | 
			
		||||
    c := 12;
 | 
			
		||||
    a := b + c;
 | 
			
		||||
    d := 9;
 | 
			
		||||
    a := (AA - b) * c;
 | 
			
		||||
    write(a);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										59
									
								
								open_set/72_branch.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								open_set/72_branch.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
  ret, a, b, c, d, e, f: integer;
 | 
			
		||||
begin
 | 
			
		||||
  ret := 0;
 | 
			
		||||
  a := 1;
 | 
			
		||||
  b := 2;
 | 
			
		||||
  c := 3;
 | 
			
		||||
  d := 4;
 | 
			
		||||
  e := 5;
 | 
			
		||||
  f := 6;
 | 
			
		||||
 | 
			
		||||
  if (a * b + c < 6) and (d <> 0) then
 | 
			
		||||
  begin
 | 
			
		||||
    if (e <> 0) or (not(a + 0 <> 0)) then
 | 
			
		||||
    begin
 | 
			
		||||
      if (c = 2) and (d + e > 2) then
 | 
			
		||||
        ret := 3
 | 
			
		||||
      else
 | 
			
		||||
      begin
 | 
			
		||||
        if (f mod c <> 0) and (e <> 0) then
 | 
			
		||||
          ret := 4
 | 
			
		||||
        else
 | 
			
		||||
        begin
 | 
			
		||||
          if (d div b + a >= 2) then
 | 
			
		||||
          begin
 | 
			
		||||
            if (e - f >= 0) or (d > 4) then
 | 
			
		||||
              ret := 6
 | 
			
		||||
            else
 | 
			
		||||
            begin
 | 
			
		||||
              if (c <> f) then
 | 
			
		||||
              begin
 | 
			
		||||
                if (b + e * d > 10) then
 | 
			
		||||
                begin
 | 
			
		||||
                  if (f = 0) then
 | 
			
		||||
                    ret := 9
 | 
			
		||||
                  else
 | 
			
		||||
                    ret := 10;
 | 
			
		||||
                end
 | 
			
		||||
                else
 | 
			
		||||
                  ret := 8;
 | 
			
		||||
              end
 | 
			
		||||
              else
 | 
			
		||||
                ret := 7;
 | 
			
		||||
            end;
 | 
			
		||||
          end
 | 
			
		||||
          else
 | 
			
		||||
            ret := 5;
 | 
			
		||||
        end;
 | 
			
		||||
      end;
 | 
			
		||||
    end
 | 
			
		||||
    else
 | 
			
		||||
      ret := 2;
 | 
			
		||||
  end
 | 
			
		||||
  else
 | 
			
		||||
    ret := 1;
 | 
			
		||||
 | 
			
		||||
  write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										13
									
								
								open_set/73_param_name.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								open_set/73_param_name.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
program main;
 | 
			
		||||
var ret:integer;
 | 
			
		||||
 | 
			
		||||
function Fn(f: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
    Fn := f * 2;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    ret := 0;
 | 
			
		||||
    ret := Fn(10);
 | 
			
		||||
    write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										13
									
								
								open_set/74_func_name.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								open_set/74_func_name.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
program main;
 | 
			
		||||
var ret, f: integer;
 | 
			
		||||
function fn:integer;
 | 
			
		||||
begin
 | 
			
		||||
    fn := 10;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    ret := 0;
 | 
			
		||||
    f := 20;
 | 
			
		||||
    ret := f;
 | 
			
		||||
    write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										146
									
								
								open_set/75_arr_init_nd.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								open_set/75_arr_init_nd.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,146 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
  ret: integer;
 | 
			
		||||
  a: array[1..5, 1..3] of integer;
 | 
			
		||||
  b: array[1..5, 1..3] of integer;
 | 
			
		||||
  c: array[1..5, 1..3] of integer;
 | 
			
		||||
  d: array[1..5, 1..3] of integer;
 | 
			
		||||
  e: array[1..5, 1..3] of integer;
 | 
			
		||||
  f: array[1..5] of integer;
 | 
			
		||||
  g: array[1..5, 1..3] of integer;
 | 
			
		||||
  h: array[1..3] of integer;
 | 
			
		||||
  i: array[1..2, 1..3, 1..4] of integer;
 | 
			
		||||
begin
 | 
			
		||||
  ret := 0;
 | 
			
		||||
 | 
			
		||||
  a[1, 1] := 0;
 | 
			
		||||
  a[1, 2] := 0;
 | 
			
		||||
  a[1, 3] := 0;
 | 
			
		||||
  a[2, 1] := 0;
 | 
			
		||||
  a[2, 2] := 0;
 | 
			
		||||
  a[2, 3] := 0;
 | 
			
		||||
  a[3, 1] := 0;
 | 
			
		||||
  a[3, 2] := 0;
 | 
			
		||||
  a[3, 3] := 0;
 | 
			
		||||
  a[4, 1] := 0;
 | 
			
		||||
  a[4, 2] := 0;
 | 
			
		||||
  a[4, 3] := 0;
 | 
			
		||||
  a[5, 1] := 0;
 | 
			
		||||
  a[5, 2] := 0;
 | 
			
		||||
  a[5, 3] := 0;
 | 
			
		||||
 | 
			
		||||
  b[1, 1] := 0;
 | 
			
		||||
  b[1, 2] := 0;
 | 
			
		||||
  b[1, 3] := 0;
 | 
			
		||||
  b[2, 1] := 0;
 | 
			
		||||
  b[2, 2] := 0;
 | 
			
		||||
  b[2, 3] := 0;
 | 
			
		||||
  b[3, 1] := 0;
 | 
			
		||||
  b[3, 2] := 0;
 | 
			
		||||
  b[3, 3] := 0;
 | 
			
		||||
  b[4, 1] := 0;
 | 
			
		||||
  b[4, 2] := 0;
 | 
			
		||||
  b[4, 3] := 0;
 | 
			
		||||
  b[5, 1] := 0;
 | 
			
		||||
  b[5, 2] := 0;
 | 
			
		||||
  b[5, 3] := 0;
 | 
			
		||||
 | 
			
		||||
  c[1, 1] := 1;
 | 
			
		||||
  c[1, 2] := 2;
 | 
			
		||||
  c[1, 3] := 3;
 | 
			
		||||
  c[2, 1] := 4;
 | 
			
		||||
  c[2, 2] := 5;
 | 
			
		||||
  c[2, 3] := 6;
 | 
			
		||||
  c[3, 1] := 7;
 | 
			
		||||
  c[3, 2] := 8;
 | 
			
		||||
  c[3, 3] := 9;
 | 
			
		||||
  c[4, 1] := 10;
 | 
			
		||||
  c[4, 2] := 11;
 | 
			
		||||
  c[4, 3] := 12;
 | 
			
		||||
  c[5, 1] := 13;
 | 
			
		||||
  c[5, 2] := 14;
 | 
			
		||||
  c[5, 3] := 15;
 | 
			
		||||
 | 
			
		||||
  d[1, 1] := 1;
 | 
			
		||||
  d[1, 2] := 2;
 | 
			
		||||
  d[1, 3] := 3;
 | 
			
		||||
  d[2, 1] := 4;
 | 
			
		||||
  d[2, 2] := 5;
 | 
			
		||||
  d[2, 3] := 6;
 | 
			
		||||
  d[3, 1] := 7;
 | 
			
		||||
  d[3, 2] := 8;
 | 
			
		||||
  d[3, 3] := 9;
 | 
			
		||||
  d[4, 1] := 10;
 | 
			
		||||
  d[4, 2] := 11;
 | 
			
		||||
  d[4, 3] := 12;
 | 
			
		||||
  d[5, 1] := 13;
 | 
			
		||||
  d[5, 2] := 14;
 | 
			
		||||
  d[5, 3] := 15;
 | 
			
		||||
 | 
			
		||||
  e[1, 1] := 1;
 | 
			
		||||
  e[1, 2] := 2;
 | 
			
		||||
  e[1, 3] := 3;
 | 
			
		||||
  e[2, 1] := 4;
 | 
			
		||||
  e[2, 2] := 5;
 | 
			
		||||
  e[2, 3] := 6;
 | 
			
		||||
  e[3, 1] := 7;
 | 
			
		||||
  e[3, 2] := 8;
 | 
			
		||||
  e[3, 3] := 9;
 | 
			
		||||
  e[4, 1] := 10;
 | 
			
		||||
  e[4, 2] := 11;
 | 
			
		||||
  e[4, 3] := 12;
 | 
			
		||||
  e[5, 1] := 13;
 | 
			
		||||
  e[5, 2] := 14;
 | 
			
		||||
  e[5, 3] := 15;
 | 
			
		||||
 | 
			
		||||
  f[1] := 0;
 | 
			
		||||
  f[2] := 0;
 | 
			
		||||
  f[3] := 0;
 | 
			
		||||
  f[4] := 0;
 | 
			
		||||
  f[5] := 0;
 | 
			
		||||
 | 
			
		||||
  g[1, 1] := 1;
 | 
			
		||||
  g[1, 2] := 2;
 | 
			
		||||
  g[1, 3] := 3;
 | 
			
		||||
  g[2, 1] := 4;
 | 
			
		||||
  g[2, 2] := 0;
 | 
			
		||||
  g[2, 3] := 0;
 | 
			
		||||
  g[3, 1] := 7;
 | 
			
		||||
  g[3, 2] := 0;
 | 
			
		||||
  g[3, 3] := 0;
 | 
			
		||||
  g[4, 1] := 10;
 | 
			
		||||
  g[4, 2] := 11;
 | 
			
		||||
  g[4, 3] := 12;
 | 
			
		||||
  g[5, 1] := 0;
 | 
			
		||||
  g[5, 2] := 0;
 | 
			
		||||
  g[5, 3] := 0;
 | 
			
		||||
 | 
			
		||||
  h[1] := 0;
 | 
			
		||||
  h[2] := 0;
 | 
			
		||||
  h[3] := 0;
 | 
			
		||||
 | 
			
		||||
  i[1, 1, 1] := 1;
 | 
			
		||||
  i[1, 1, 2] := 2;
 | 
			
		||||
  i[1, 1, 3] := 3;
 | 
			
		||||
  i[1, 1, 4] := 4;
 | 
			
		||||
  i[1, 2, 1] := 5;
 | 
			
		||||
  i[1, 2, 2] := 0;
 | 
			
		||||
  i[1, 2, 3] := 0;
 | 
			
		||||
  i[1, 2, 4] := 0;
 | 
			
		||||
  i[2, 1, 1] := 0;
 | 
			
		||||
  i[2, 1, 2] := 0;
 | 
			
		||||
  i[2, 1, 3] := 0;
 | 
			
		||||
  i[2, 1, 4] := 0;
 | 
			
		||||
  i[2, 2, 1] := 0;
 | 
			
		||||
  i[2, 2, 2] := 0;
 | 
			
		||||
  i[2, 2, 3] := 0;
 | 
			
		||||
  i[2, 2, 4] := 0;
 | 
			
		||||
  i[2, 3, 1] := 0;
 | 
			
		||||
  i[2, 3, 2] := 0;
 | 
			
		||||
  i[2, 3, 3] := 0;
 | 
			
		||||
  i[2, 3, 4] := 0;
 | 
			
		||||
 | 
			
		||||
  ret := 4;
 | 
			
		||||
 | 
			
		||||
  write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										89
									
								
								open_set/76_global_arr_init.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								open_set/76_global_arr_init.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
  ret: integer;
 | 
			
		||||
  a0: array[0..2] of integer;
 | 
			
		||||
  b0: array[0..3] of integer;
 | 
			
		||||
  c0: array[0..6] of integer;
 | 
			
		||||
  c: array[0..4, 0..2] of integer;
 | 
			
		||||
  d: array[0..4, 0..2] of integer;
 | 
			
		||||
  e: array[0..4, 0..2] of integer;
 | 
			
		||||
 | 
			
		||||
procedure InitializeArrays;
 | 
			
		||||
begin
 | 
			
		||||
  // Initialize arrays a0, b0, and c0 element by element
 | 
			
		||||
  a0[0] := 0;
 | 
			
		||||
  a0[1] := 0;
 | 
			
		||||
  a0[2] := 0;
 | 
			
		||||
 | 
			
		||||
  b0[0] := 0;
 | 
			
		||||
  b0[1] := 1;
 | 
			
		||||
  b0[2] := 0;
 | 
			
		||||
  b0[3] := 0;
 | 
			
		||||
 | 
			
		||||
  c0[0] := 2;
 | 
			
		||||
  c0[1] := 8;
 | 
			
		||||
  c0[2] := 6;
 | 
			
		||||
  c0[3] := 3;
 | 
			
		||||
  c0[4] := 9;
 | 
			
		||||
  c0[5] := 1;
 | 
			
		||||
  c0[6] := 5;
 | 
			
		||||
 | 
			
		||||
  // Initialize arrays c, d, and e element by element
 | 
			
		||||
  c[0, 0] := 1;
 | 
			
		||||
  c[0, 1] := 2;
 | 
			
		||||
  c[0, 2] := 3;
 | 
			
		||||
  c[1, 0] := 4;
 | 
			
		||||
  c[1, 1] := 5;
 | 
			
		||||
  c[1, 2] := 6;
 | 
			
		||||
  c[2, 0] := 7;
 | 
			
		||||
  c[2, 1] := 8;
 | 
			
		||||
  c[2, 2] := 9;
 | 
			
		||||
  c[3, 0] := 10;
 | 
			
		||||
  c[3, 1] := 11;
 | 
			
		||||
  c[3, 2] := 12;
 | 
			
		||||
  c[4, 0] := 13;
 | 
			
		||||
  c[4, 1] := 14;
 | 
			
		||||
  c[4, 2] := 15;
 | 
			
		||||
 | 
			
		||||
  d[0, 0] := 1;
 | 
			
		||||
  d[0, 1] := 2;
 | 
			
		||||
  d[0, 2] := 3;
 | 
			
		||||
  d[1, 0] := 4;
 | 
			
		||||
  d[1, 1] := 5;
 | 
			
		||||
  d[1, 2] := 6;
 | 
			
		||||
  d[2, 0] := 7;
 | 
			
		||||
  d[2, 1] := 8;
 | 
			
		||||
  d[2, 2] := 9;
 | 
			
		||||
  d[3, 0] := 10;
 | 
			
		||||
  d[3, 1] := 11;
 | 
			
		||||
  d[3, 2] := 12;
 | 
			
		||||
  d[4, 0] := 13;
 | 
			
		||||
  d[4, 1] := 14;
 | 
			
		||||
  d[4, 2] := 15;
 | 
			
		||||
 | 
			
		||||
  e[0, 0] := 1;
 | 
			
		||||
  e[0, 1] := 2;
 | 
			
		||||
  e[0, 2] := 3;
 | 
			
		||||
  e[1, 0] := 4;
 | 
			
		||||
  e[1, 1] := 5;
 | 
			
		||||
  e[1, 2] := 6;
 | 
			
		||||
  e[2, 0] := 7;
 | 
			
		||||
  e[2, 1] := 8;
 | 
			
		||||
  e[2, 2] := 9;
 | 
			
		||||
  e[3, 0] := 10;
 | 
			
		||||
  e[3, 1] := 11;
 | 
			
		||||
  e[3, 2] := 12;
 | 
			
		||||
  e[4, 0] := 13;
 | 
			
		||||
  e[4, 1] := 14;
 | 
			
		||||
  e[4, 2] := 15;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  ret := 0;
 | 
			
		||||
 | 
			
		||||
  InitializeArrays;
 | 
			
		||||
 | 
			
		||||
  ret := 5;
 | 
			
		||||
 | 
			
		||||
  write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										123
									
								
								open_set/77_BST.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								open_set/77_BST.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,123 @@
 | 
			
		||||
100
 | 
			
		||||
88
 | 
			
		||||
10
 | 
			
		||||
65
 | 
			
		||||
34
 | 
			
		||||
3
 | 
			
		||||
69
 | 
			
		||||
54
 | 
			
		||||
14
 | 
			
		||||
96
 | 
			
		||||
35
 | 
			
		||||
76
 | 
			
		||||
0
 | 
			
		||||
59
 | 
			
		||||
12
 | 
			
		||||
4
 | 
			
		||||
94
 | 
			
		||||
91
 | 
			
		||||
67
 | 
			
		||||
40
 | 
			
		||||
44
 | 
			
		||||
61
 | 
			
		||||
30
 | 
			
		||||
92
 | 
			
		||||
46
 | 
			
		||||
62
 | 
			
		||||
98
 | 
			
		||||
22
 | 
			
		||||
22
 | 
			
		||||
47
 | 
			
		||||
15
 | 
			
		||||
14
 | 
			
		||||
82
 | 
			
		||||
34
 | 
			
		||||
91
 | 
			
		||||
85
 | 
			
		||||
18
 | 
			
		||||
80
 | 
			
		||||
77
 | 
			
		||||
35
 | 
			
		||||
18
 | 
			
		||||
50
 | 
			
		||||
4
 | 
			
		||||
56
 | 
			
		||||
45
 | 
			
		||||
78
 | 
			
		||||
48
 | 
			
		||||
73
 | 
			
		||||
94
 | 
			
		||||
80
 | 
			
		||||
45
 | 
			
		||||
50
 | 
			
		||||
1
 | 
			
		||||
74
 | 
			
		||||
79
 | 
			
		||||
96
 | 
			
		||||
60
 | 
			
		||||
51
 | 
			
		||||
35
 | 
			
		||||
42
 | 
			
		||||
92
 | 
			
		||||
88
 | 
			
		||||
99
 | 
			
		||||
82
 | 
			
		||||
98
 | 
			
		||||
99
 | 
			
		||||
13
 | 
			
		||||
9
 | 
			
		||||
79
 | 
			
		||||
68
 | 
			
		||||
61
 | 
			
		||||
92
 | 
			
		||||
79
 | 
			
		||||
87
 | 
			
		||||
79
 | 
			
		||||
41
 | 
			
		||||
61
 | 
			
		||||
54
 | 
			
		||||
74
 | 
			
		||||
11
 | 
			
		||||
63
 | 
			
		||||
11
 | 
			
		||||
60
 | 
			
		||||
78
 | 
			
		||||
16
 | 
			
		||||
4
 | 
			
		||||
55
 | 
			
		||||
22
 | 
			
		||||
19
 | 
			
		||||
90
 | 
			
		||||
9
 | 
			
		||||
72
 | 
			
		||||
48
 | 
			
		||||
25
 | 
			
		||||
90
 | 
			
		||||
96
 | 
			
		||||
25
 | 
			
		||||
85
 | 
			
		||||
63
 | 
			
		||||
34
 | 
			
		||||
66
 | 
			
		||||
 | 
			
		||||
20
 | 
			
		||||
35
 | 
			
		||||
91
 | 
			
		||||
24
 | 
			
		||||
57
 | 
			
		||||
3
 | 
			
		||||
14
 | 
			
		||||
56
 | 
			
		||||
91
 | 
			
		||||
83
 | 
			
		||||
37
 | 
			
		||||
38
 | 
			
		||||
80
 | 
			
		||||
55
 | 
			
		||||
63
 | 
			
		||||
53
 | 
			
		||||
62
 | 
			
		||||
57
 | 
			
		||||
71
 | 
			
		||||
20
 | 
			
		||||
49
 | 
			
		||||
							
								
								
									
										143
									
								
								open_set/77_BST.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								open_set/77_BST.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,143 @@
 | 
			
		||||
program BinarySearchTree;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  value: array[0..9999] of integer;
 | 
			
		||||
  left_child: array[0..9999] of integer;
 | 
			
		||||
  right_child: array[0..9999] of integer;
 | 
			
		||||
  now: integer;
 | 
			
		||||
  ret, n, readN, i, root: integer;
 | 
			
		||||
 | 
			
		||||
function search(root, x: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
  if (root = -1) or (value[root] = x) then
 | 
			
		||||
    search := root
 | 
			
		||||
  else 
 | 
			
		||||
  begin
 | 
			
		||||
    if (x > value[root]) then
 | 
			
		||||
      search := search(right_child[root], x)
 | 
			
		||||
    else
 | 
			
		||||
      search := search(left_child[root], x);
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function find_minimum(root: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
  if (root = -1) then
 | 
			
		||||
    find_minimum := -1
 | 
			
		||||
  else 
 | 
			
		||||
  begin
 | 
			
		||||
    if (left_child[root] <> -1) then
 | 
			
		||||
      find_minimum := find_minimum(left_child[root])
 | 
			
		||||
    else
 | 
			
		||||
      find_minimum := root;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function new_node(x: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
  value[now] := x;
 | 
			
		||||
  left_child[now] := -1;
 | 
			
		||||
  right_child[now] := -1;
 | 
			
		||||
  new_node := now;
 | 
			
		||||
  now := now + 1;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function insert(root, x: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
  if (root = -1) then
 | 
			
		||||
    insert := new_node(x)
 | 
			
		||||
  else 
 | 
			
		||||
  begin
 | 
			
		||||
    if (x > value[root]) then
 | 
			
		||||
      right_child[root] := insert(right_child[root], x)
 | 
			
		||||
    else
 | 
			
		||||
      left_child[root] := insert(left_child[root], x);
 | 
			
		||||
  end;
 | 
			
		||||
  insert := root;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function delete_node(root, x: integer): integer;
 | 
			
		||||
var
 | 
			
		||||
  tmp: integer;
 | 
			
		||||
begin
 | 
			
		||||
  if (x > value[root]) then
 | 
			
		||||
begin
 | 
			
		||||
    right_child[root] := delete_node(right_child[root], x);
 | 
			
		||||
end
 | 
			
		||||
else
 | 
			
		||||
begin
 | 
			
		||||
    if (x < value[root]) then
 | 
			
		||||
    begin
 | 
			
		||||
        left_child[root] := delete_node(left_child[root], x);
 | 
			
		||||
    end
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
        if (left_child[root] = -1) and (right_child[root] = -1) then
 | 
			
		||||
        begin
 | 
			
		||||
            delete_node := -1;
 | 
			
		||||
        end
 | 
			
		||||
        else
 | 
			
		||||
        begin
 | 
			
		||||
            if (left_child[root] = -1) or (right_child[root] = -1) then
 | 
			
		||||
            begin
 | 
			
		||||
                if (left_child[root] = -1) then
 | 
			
		||||
                begin
 | 
			
		||||
                    delete_node := right_child[root];
 | 
			
		||||
                end
 | 
			
		||||
                else
 | 
			
		||||
                begin
 | 
			
		||||
                    delete_node := left_child[root];
 | 
			
		||||
                end;
 | 
			
		||||
            end
 | 
			
		||||
            else
 | 
			
		||||
            begin
 | 
			
		||||
                tmp := find_minimum(right_child[root]);
 | 
			
		||||
                value[root] := value[tmp];
 | 
			
		||||
                right_child[root] := delete_node(right_child[root], value[tmp]);
 | 
			
		||||
            end;
 | 
			
		||||
        end;
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
  delete_node := root;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure inorder(root: integer);
 | 
			
		||||
begin
 | 
			
		||||
  if (root <> -1) then
 | 
			
		||||
  begin
 | 
			
		||||
    inorder(left_child[root]);
 | 
			
		||||
    write(value[root], ' ');
 | 
			
		||||
    inorder(right_child[root]);
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  ret := 0;
 | 
			
		||||
  now := 0;
 | 
			
		||||
 | 
			
		||||
  read(n);
 | 
			
		||||
  if (n = 0) then
 | 
			
		||||
    ret := 0;
 | 
			
		||||
 | 
			
		||||
  read(readN);
 | 
			
		||||
  root := new_node(readN);
 | 
			
		||||
 | 
			
		||||
  for i := 1 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    read(readN);
 | 
			
		||||
    insert(root, readN);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  inorder(root);
 | 
			
		||||
 | 
			
		||||
  read(n);
 | 
			
		||||
  for i := 1 to n do
 | 
			
		||||
  begin
 | 
			
		||||
    read(readN);
 | 
			
		||||
    root := delete_node(root, readN);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  inorder(root);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										8
									
								
								open_set/78_dp.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								open_set/78_dp.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
7 2
 | 
			
		||||
2
 | 
			
		||||
1
 | 
			
		||||
1
 | 
			
		||||
2
 | 
			
		||||
2
 | 
			
		||||
1
 | 
			
		||||
1
 | 
			
		||||
							
								
								
									
										58
									
								
								open_set/78_dp.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								open_set/78_dp.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
			
		||||
program main;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  t: array[0..1004, 0..1] of integer;
 | 
			
		||||
  dp: array[0..1004, 0..34] of integer;
 | 
			
		||||
  TT, W, x, i, j, res: integer;
 | 
			
		||||
 | 
			
		||||
function getint: integer;
 | 
			
		||||
var
 | 
			
		||||
  n: integer;
 | 
			
		||||
begin
 | 
			
		||||
  read(n);
 | 
			
		||||
  getint := n;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  for i := 0 to 1004 do
 | 
			
		||||
  begin
 | 
			
		||||
    t[i, 0] := 0;
 | 
			
		||||
    t[i, 1] := 0;
 | 
			
		||||
    for j := 0 to 34 do
 | 
			
		||||
      dp[i, j] := 0;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  TT := getint();
 | 
			
		||||
  W := getint();
 | 
			
		||||
  for i := 1 to TT do
 | 
			
		||||
  begin
 | 
			
		||||
    x := getint();
 | 
			
		||||
    t[i, x mod 2] := 1;
 | 
			
		||||
    dp[i, 0] := dp[i - 1, 0] + t[i, 1];
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  for i := 1 to TT do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 1 to W do
 | 
			
		||||
    begin
 | 
			
		||||
      if (dp[i - 1, j] + t[i, (j + 1) mod 2] > dp[i - 1, j - 1] + t[i, (j + 1) mod 2]) then
 | 
			
		||||
      begin
 | 
			
		||||
        dp[i, j] := dp[i - 1, j] + t[i, (j + 1) mod 2];
 | 
			
		||||
      end
 | 
			
		||||
      else
 | 
			
		||||
      begin
 | 
			
		||||
        dp[i, j] := dp[i - 1, j - 1] + t[i, (j + 1) mod 2];
 | 
			
		||||
      end;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  res := 0;
 | 
			
		||||
  for j := 0 to W do
 | 
			
		||||
  begin
 | 
			
		||||
    if res < dp[TT, j] then
 | 
			
		||||
    begin
 | 
			
		||||
      res := dp[TT, j];
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
  write(res);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										91
									
								
								open_set/79_graph_coloring.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								open_set/79_graph_coloring.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
			
		||||
program main;
 | 
			
		||||
const
 | 
			
		||||
space = 32;
 | 
			
		||||
ne = 'Not exist';
 | 
			
		||||
var
 | 
			
		||||
graph: array[0..3, 0..3] of integer;
 | 
			
		||||
color: array[0..3] of integer;
 | 
			
		||||
i, m: integer;
 | 
			
		||||
 | 
			
		||||
procedure printSolution();
 | 
			
		||||
var i: integer;
 | 
			
		||||
begin
 | 
			
		||||
  for i := 0 to 3 do
 | 
			
		||||
    write(color[i]);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure printMessage();
 | 
			
		||||
begin
 | 
			
		||||
  write(ne);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function isSafe():integer;
 | 
			
		||||
var i,j: integer;
 | 
			
		||||
begin
 | 
			
		||||
  isSafe := 1;
 | 
			
		||||
  for i := 0 to 3 do
 | 
			
		||||
    for j := i + 1 to 3 do
 | 
			
		||||
      if (graph[i, j] <> 0) and (color[j] = color[i]) then
 | 
			
		||||
        isSafe := 0;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function graphColoring(m, i: integer): integer;
 | 
			
		||||
var
 | 
			
		||||
  j: integer;
 | 
			
		||||
  foundSolution: boolean;
 | 
			
		||||
begin
 | 
			
		||||
  foundSolution := false;
 | 
			
		||||
 | 
			
		||||
  if (i = 4) then
 | 
			
		||||
  begin
 | 
			
		||||
    if (isSafe() <> 0) then
 | 
			
		||||
    begin
 | 
			
		||||
      printSolution();
 | 
			
		||||
      graphColoring := 1;
 | 
			
		||||
      foundSolution := True;
 | 
			
		||||
    end;
 | 
			
		||||
  end
 | 
			
		||||
  else
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 1 to m do
 | 
			
		||||
    begin
 | 
			
		||||
      color[i] := j;
 | 
			
		||||
      if (graphColoring(m, i + 1) <> 0) then
 | 
			
		||||
      begin
 | 
			
		||||
        foundSolution := True;
 | 
			
		||||
        Break;
 | 
			
		||||
      end;
 | 
			
		||||
      color[i] := 0;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  if foundSolution then
 | 
			
		||||
    graphColoring := 1
 | 
			
		||||
  else
 | 
			
		||||
    graphColoring := 0;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  graph[0, 0] := 0;
 | 
			
		||||
  graph[0, 1] := 1;
 | 
			
		||||
  graph[0, 2] := 1;
 | 
			
		||||
  graph[0, 3] := 1;
 | 
			
		||||
  graph[1, 0] := 1;
 | 
			
		||||
  graph[1, 1] := 0;
 | 
			
		||||
  graph[1, 2] := 1;
 | 
			
		||||
  graph[1, 3] := 0;
 | 
			
		||||
  graph[2, 0] := 1;
 | 
			
		||||
  graph[2, 1] := 1;
 | 
			
		||||
  graph[2, 2] := 0;
 | 
			
		||||
  graph[2, 3] := 1;
 | 
			
		||||
  graph[3, 0] := 1;
 | 
			
		||||
  graph[3, 1] := 0;
 | 
			
		||||
  graph[3, 2] := 1;
 | 
			
		||||
  graph[3, 3] := 0;
 | 
			
		||||
  m := 3;
 | 
			
		||||
  for i := 0 to 3 do
 | 
			
		||||
    color[i] := 0;
 | 
			
		||||
  if graphColoring(m, 0) = 0 then
 | 
			
		||||
    printMessage;
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										2
									
								
								open_set/80_k_smallest.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								open_set/80_k_smallest.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
12 5
 | 
			
		||||
11 3 2 1 15 5 4 45 88 96 50 45
 | 
			
		||||
							
								
								
									
										84
									
								
								open_set/80_k_smallest.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								open_set/80_k_smallest.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
			
		||||
program FindSmallest;
 | 
			
		||||
 | 
			
		||||
const
 | 
			
		||||
  space = 32;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  arr: array[0..999] of integer;
 | 
			
		||||
  n, k, i, low, high: integer;
 | 
			
		||||
 | 
			
		||||
procedure swap(a, b: integer);
 | 
			
		||||
var
 | 
			
		||||
  tmp: integer;
 | 
			
		||||
begin
 | 
			
		||||
  tmp := arr[a];
 | 
			
		||||
  arr[a] := arr[b];
 | 
			
		||||
  arr[b] := tmp;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function findPivot(start, endIndex: integer): integer;
 | 
			
		||||
var
 | 
			
		||||
  pivot, pIndex, i: integer;
 | 
			
		||||
begin
 | 
			
		||||
  pivot := arr[endIndex];
 | 
			
		||||
  pIndex := start;
 | 
			
		||||
 | 
			
		||||
  for i := start to endIndex - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    if arr[i] <= pivot then
 | 
			
		||||
    begin
 | 
			
		||||
      swap(i, pIndex);
 | 
			
		||||
      pIndex := pIndex + 1;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
  swap(pIndex, endIndex);
 | 
			
		||||
  findPivot := pIndex;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure findSmallest(low, high, k, n: integer);
 | 
			
		||||
var
 | 
			
		||||
  pIndex, i: integer;
 | 
			
		||||
begin
 | 
			
		||||
  if low <> high then
 | 
			
		||||
  begin
 | 
			
		||||
    pIndex := findPivot(low, high);
 | 
			
		||||
    if k = pIndex then
 | 
			
		||||
    begin
 | 
			
		||||
      for i := 0 to pIndex - 1 do
 | 
			
		||||
      begin
 | 
			
		||||
        write(arr[i]);
 | 
			
		||||
      end;
 | 
			
		||||
    end
 | 
			
		||||
    else if k < pIndex then
 | 
			
		||||
    begin
 | 
			
		||||
      findSmallest(low, pIndex - 1, k, n);
 | 
			
		||||
    end
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
      findSmallest(pIndex + 1, high, k, n);
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function getint: integer;
 | 
			
		||||
var
 | 
			
		||||
  n: integer;
 | 
			
		||||
begin
 | 
			
		||||
  read(n);
 | 
			
		||||
  getint := n;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  n := getint;
 | 
			
		||||
  k := getint;
 | 
			
		||||
  
 | 
			
		||||
  for i := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    arr[i] := getint;
 | 
			
		||||
  end;
 | 
			
		||||
  
 | 
			
		||||
  low := 0;
 | 
			
		||||
  high := n - 1;
 | 
			
		||||
  
 | 
			
		||||
  findSmallest(low, high, k, n);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										28
									
								
								open_set/81_maximal_clique.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								open_set/81_maximal_clique.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
20 27
 | 
			
		||||
13 5
 | 
			
		||||
3 18
 | 
			
		||||
3 20
 | 
			
		||||
11 1
 | 
			
		||||
5 14
 | 
			
		||||
7 9
 | 
			
		||||
20 19
 | 
			
		||||
13 16
 | 
			
		||||
12 20
 | 
			
		||||
7 5
 | 
			
		||||
18 2
 | 
			
		||||
11 14
 | 
			
		||||
11 6
 | 
			
		||||
1 13
 | 
			
		||||
1 10
 | 
			
		||||
3 17
 | 
			
		||||
3 1
 | 
			
		||||
8 12
 | 
			
		||||
12 20
 | 
			
		||||
9 2
 | 
			
		||||
6 10
 | 
			
		||||
19 15
 | 
			
		||||
18 11
 | 
			
		||||
19 12
 | 
			
		||||
6 20
 | 
			
		||||
18 2
 | 
			
		||||
20 16
 | 
			
		||||
							
								
								
									
										60
									
								
								open_set/81_maximal_clique.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								open_set/81_maximal_clique.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
program MaxClique;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  store: array[0..29] of integer;
 | 
			
		||||
  n, m: integer;
 | 
			
		||||
  graph: array[0..29, 0..29] of integer;
 | 
			
		||||
  edges: array[0..599, 0..1] of integer;
 | 
			
		||||
  i, ret: integer;
 | 
			
		||||
 | 
			
		||||
function is_clique(num: integer): integer;
 | 
			
		||||
var
 | 
			
		||||
  i, j: integer;
 | 
			
		||||
begin
 | 
			
		||||
  is_clique := 1;
 | 
			
		||||
  for i := 1 to num - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := i + 1 to num - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
      if graph[store[i], store[j]] = 0 then
 | 
			
		||||
        is_clique := 0;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function maxCliques(i, k: integer): integer;
 | 
			
		||||
var
 | 
			
		||||
  max_, j, tmp: integer;
 | 
			
		||||
begin
 | 
			
		||||
  max_ := 0;
 | 
			
		||||
  for j := 1 to n do
 | 
			
		||||
  begin
 | 
			
		||||
    store[k] := j;
 | 
			
		||||
    if is_clique(k + 1) <> 0 then
 | 
			
		||||
    begin
 | 
			
		||||
      if k > max_ then
 | 
			
		||||
        max_ := k;
 | 
			
		||||
      tmp := maxCliques(j, k + 1);
 | 
			
		||||
      if tmp > max_ then
 | 
			
		||||
        max_ := tmp;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
  maxCliques := max_;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  read(n);
 | 
			
		||||
  read(m);
 | 
			
		||||
  for i := 0 to m - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    read(edges[i, 0]);
 | 
			
		||||
    read(edges[i, 1]);
 | 
			
		||||
  end;
 | 
			
		||||
  for i := 0 to m - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    graph[edges[i, 0], edges[i, 1]] := 1;
 | 
			
		||||
    graph[edges[i, 1], edges[i, 0]] := 1;
 | 
			
		||||
  end;
 | 
			
		||||
  ret := maxCliques(0, 1);
 | 
			
		||||
  write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										1001
									
								
								open_set/82_prim.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1001
									
								
								open_set/82_prim.in
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										80
									
								
								open_set/82_prim.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								open_set/82_prim.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
n, m: integer;
 | 
			
		||||
ret,i: integer;
 | 
			
		||||
u,v,c,fa: array [0..1004] of integer;
 | 
			
		||||
 | 
			
		||||
function find(x: integer):integer;
 | 
			
		||||
var asdf: integer;
 | 
			
		||||
begin
 | 
			
		||||
  if x = fa[x] then
 | 
			
		||||
    find := x
 | 
			
		||||
  else
 | 
			
		||||
  begin
 | 
			
		||||
    asdf := find(fa[x]);
 | 
			
		||||
    fa[x] := asdf;
 | 
			
		||||
    find := asdf;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function same(x,y: integer):integer;
 | 
			
		||||
begin
 | 
			
		||||
  x := find(x);
 | 
			
		||||
  y := find(y);
 | 
			
		||||
  if x = y then
 | 
			
		||||
    same := 1
 | 
			
		||||
  else
 | 
			
		||||
    same := 0;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function prim:integer;
 | 
			
		||||
var i,j,t,res: integer;
 | 
			
		||||
begin
 | 
			
		||||
  for i := 0 to m - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := i + 1 to m - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
      if c[i] > c[j] then
 | 
			
		||||
      begin
 | 
			
		||||
        t := u[i];
 | 
			
		||||
        u[i] := u[j];
 | 
			
		||||
        u[j] := t;
 | 
			
		||||
        t := v[i];
 | 
			
		||||
        v[i] := v[j];
 | 
			
		||||
        v[j] := t;
 | 
			
		||||
        t := c[i];
 | 
			
		||||
        c[i] := c[j];
 | 
			
		||||
        c[j] := t;
 | 
			
		||||
      end;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  for i := 1 to n do
 | 
			
		||||
    fa[i] := i;
 | 
			
		||||
  res := 0;
 | 
			
		||||
  for i := 0 to m - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    if same(u[i], v[i]) = 0 then
 | 
			
		||||
    begin
 | 
			
		||||
      res := res + c[i];
 | 
			
		||||
      fa[find(u[i])] := v[i];
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  prim := res;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  ret := 0;
 | 
			
		||||
  read(n);
 | 
			
		||||
  read(m);
 | 
			
		||||
  for i := 0 to m - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    read(u[i]);
 | 
			
		||||
    read(v[i]);
 | 
			
		||||
    read(c[i]);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  ret := prim;
 | 
			
		||||
  write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										3
									
								
								open_set/83_sort.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								open_set/83_sort.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
20
 | 
			
		||||
1 2 3 4 5 6 7 8 9 0
 | 
			
		||||
0 9 8 7 6 5 4 3 2 1
 | 
			
		||||
							
								
								
									
										92
									
								
								open_set/83_sort.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								open_set/83_sort.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
n,ret,i,t: integer;
 | 
			
		||||
x,a,b,c: array[0..100004] of integer;
 | 
			
		||||
cnt: array [0..400019] of integer;
 | 
			
		||||
 | 
			
		||||
procedure sortA;
 | 
			
		||||
var i, j, t:integer;
 | 
			
		||||
begin
 | 
			
		||||
    for i := 0 to n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        for j := i + 1 to n - 1 do
 | 
			
		||||
        begin
 | 
			
		||||
            if a[i] > a[j] then
 | 
			
		||||
            begin
 | 
			
		||||
                t := a[i];
 | 
			
		||||
                a[i] := a[j];
 | 
			
		||||
                a[j] := t;
 | 
			
		||||
            end;
 | 
			
		||||
        end;
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure sortB;
 | 
			
		||||
var mx,i,j,now: integer;
 | 
			
		||||
begin
 | 
			
		||||
    mx := -100;
 | 
			
		||||
    for i := 0 to n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        cnt[b[i]] := cnt[b[i]] + 1;
 | 
			
		||||
        if b[i] > mx then
 | 
			
		||||
            mx := b[i];
 | 
			
		||||
    end;
 | 
			
		||||
    now := 0;
 | 
			
		||||
    for i := 0 to mx do
 | 
			
		||||
    begin
 | 
			
		||||
        for j := 0 to cnt[i] - 1 do
 | 
			
		||||
        begin
 | 
			
		||||
            b[now] := i;
 | 
			
		||||
            now := now + 1;
 | 
			
		||||
        end;
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure sortC;
 | 
			
		||||
var i,j,id: integer;
 | 
			
		||||
begin
 | 
			
		||||
    for i := 0 to n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        id := i;
 | 
			
		||||
        for j := i + 1 to n - 1 do
 | 
			
		||||
        begin
 | 
			
		||||
            if c[j] < c[id] then
 | 
			
		||||
                id := j;
 | 
			
		||||
        end;
 | 
			
		||||
        t := c[i];
 | 
			
		||||
        c[i] := c[id];
 | 
			
		||||
        c[id] := t;
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    ret := 0;
 | 
			
		||||
    read(n);
 | 
			
		||||
 | 
			
		||||
    for i := 0 to n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        read(a[i]);
 | 
			
		||||
        b[i] := a[i];
 | 
			
		||||
        c[i] := b[i];
 | 
			
		||||
    end;
 | 
			
		||||
 | 
			
		||||
    sortA;
 | 
			
		||||
    sortB;
 | 
			
		||||
    sortC;
 | 
			
		||||
 | 
			
		||||
    for i := 0 to n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        b[i] := b[i] - a[i];
 | 
			
		||||
        c[i] := c[i] - b[i] -a[i];
 | 
			
		||||
    end;
 | 
			
		||||
 | 
			
		||||
    for i :=  0 to n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        if b[i] <> 0 then
 | 
			
		||||
            ret := 1;
 | 
			
		||||
        if c[i] <> 0 then
 | 
			
		||||
            ret := 2;
 | 
			
		||||
    end;
 | 
			
		||||
    ret := 0;
 | 
			
		||||
    write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										28
									
								
								open_set/84_union_find.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								open_set/84_union_find.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
20 27
 | 
			
		||||
13 5
 | 
			
		||||
3 18
 | 
			
		||||
3 20
 | 
			
		||||
11 1
 | 
			
		||||
5 14
 | 
			
		||||
7 9
 | 
			
		||||
20 19
 | 
			
		||||
13 16
 | 
			
		||||
12 20
 | 
			
		||||
7 5
 | 
			
		||||
18 2
 | 
			
		||||
11 14
 | 
			
		||||
11 6
 | 
			
		||||
1 13
 | 
			
		||||
1 10
 | 
			
		||||
3 17
 | 
			
		||||
3 1
 | 
			
		||||
8 12
 | 
			
		||||
12 20
 | 
			
		||||
9 2
 | 
			
		||||
6 10
 | 
			
		||||
19 15
 | 
			
		||||
18 11
 | 
			
		||||
19 12
 | 
			
		||||
6 20
 | 
			
		||||
18 2
 | 
			
		||||
20 16
 | 
			
		||||
							
								
								
									
										60
									
								
								open_set/84_union_find.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								open_set/84_union_find.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
program main;
 | 
			
		||||
  
 | 
			
		||||
var
 | 
			
		||||
  parent: array[0..1004] of integer;
 | 
			
		||||
  n, m, i, p, q, clusters: integer;
 | 
			
		||||
 | 
			
		||||
function getint: integer;
 | 
			
		||||
begin
 | 
			
		||||
  read(getint);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function find(root: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
  if parent[root] = root then
 | 
			
		||||
    find := root
 | 
			
		||||
  else
 | 
			
		||||
  begin
 | 
			
		||||
    parent[root] := find(parent[root]);
 | 
			
		||||
    find := parent[root];
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure merge(p, q: integer);
 | 
			
		||||
var
 | 
			
		||||
  root_p, root_q: integer;
 | 
			
		||||
begin
 | 
			
		||||
  root_p := find(p);
 | 
			
		||||
  root_q := find(q);
 | 
			
		||||
  if root_p <> root_q then
 | 
			
		||||
  begin
 | 
			
		||||
    parent[root_q] := root_p;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  n := getint();
 | 
			
		||||
  m := getint();
 | 
			
		||||
  
 | 
			
		||||
  for i := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    parent[i] := i;
 | 
			
		||||
  end;
 | 
			
		||||
  
 | 
			
		||||
  for i := 0 to m - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    p := getint();
 | 
			
		||||
    q := getint();
 | 
			
		||||
    merge(p, q);
 | 
			
		||||
  end;
 | 
			
		||||
  
 | 
			
		||||
  clusters := 0;
 | 
			
		||||
  for i := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    if parent[i] = i then
 | 
			
		||||
      clusters := clusters + 1;
 | 
			
		||||
  end;
 | 
			
		||||
  
 | 
			
		||||
  write(clusters);
 | 
			
		||||
  read(clusters);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										10
									
								
								open_set/85_matrix_multiply.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								open_set/85_matrix_multiply.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
4 4
 | 
			
		||||
1 2 3 4
 | 
			
		||||
5 6 7 8
 | 
			
		||||
9 10 11 12
 | 
			
		||||
13 14 15 16
 | 
			
		||||
4 3
 | 
			
		||||
9 5 1
 | 
			
		||||
10 6 2 
 | 
			
		||||
11 7 3
 | 
			
		||||
12 8 4
 | 
			
		||||
							
								
								
									
										56
									
								
								open_set/85_matrix_multiply.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								open_set/85_matrix_multiply.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
program main;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  a,b,res: array[1..100, 1..100] of integer;
 | 
			
		||||
  n1, m1, n2, m2, i, j, k: integer;
 | 
			
		||||
 | 
			
		||||
procedure matrix_multiply;
 | 
			
		||||
begin
 | 
			
		||||
  for i := 1 to m1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 1 to n2 do
 | 
			
		||||
    begin
 | 
			
		||||
      for k := 1 to n1 do
 | 
			
		||||
      begin
 | 
			
		||||
        res[i][j] := res[i][j] + a[i][k] * b[k][j];
 | 
			
		||||
      end;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function getint: integer;
 | 
			
		||||
begin
 | 
			
		||||
  read(getint);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  m1 := getint;
 | 
			
		||||
  n1 := getint;
 | 
			
		||||
  for i := 1 to m1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 1 to n1 do
 | 
			
		||||
    begin
 | 
			
		||||
      a[i][j] := getint;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  m2 := getint;
 | 
			
		||||
  n2 := getint;
 | 
			
		||||
  for i := 1 to m2 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 1 to n2 do
 | 
			
		||||
    begin
 | 
			
		||||
      b[i][j] := getint;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  matrix_multiply;
 | 
			
		||||
 | 
			
		||||
  for i := 1 to m1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 1 to n2 do
 | 
			
		||||
    begin
 | 
			
		||||
      write(res[i][j]);
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										79
									
								
								open_set/86_side_effect2.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								open_set/86_side_effect2.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
sum, i, ans: integer;
 | 
			
		||||
arr: array[0..19] of integer;
 | 
			
		||||
 | 
			
		||||
function f(i, j: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
    sum := sum + 1;
 | 
			
		||||
    if (i >= j) or (i >= 20) then
 | 
			
		||||
        f := 0
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
        arr[i] := 1;
 | 
			
		||||
        if i = 0 then
 | 
			
		||||
            f := arr[0]
 | 
			
		||||
        else
 | 
			
		||||
            f := arr[i - 1];
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function g(i,j: integer):integer;
 | 
			
		||||
begin
 | 
			
		||||
    sum := sum + 2;
 | 
			
		||||
    if (i >= j) or (i >= 20) then
 | 
			
		||||
        g := 1
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
        arr[i] := 0;
 | 
			
		||||
        if i = 0 then
 | 
			
		||||
            g := arr[0]
 | 
			
		||||
        else
 | 
			
		||||
            g := arr[i - 1];
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function h(i: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
    sum := sum + 3;
 | 
			
		||||
    if (i < 0) or (i >= 20) then
 | 
			
		||||
        h := 0
 | 
			
		||||
    else
 | 
			
		||||
        h := arr[i];
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    for i := 0 to 19 do
 | 
			
		||||
        arr[i] := 0;
 | 
			
		||||
    for i := 0 to 19 do
 | 
			
		||||
    begin
 | 
			
		||||
        if (f(0, i) <> 0) and (f(1, i) <> 0) and (f(2, i) <> 0) and (f(3, i) <> 0) and (f(4, i) <> 0) and
 | 
			
		||||
            (f(5, i) <> 0) and (f(6, i) <> 0) and (f(7, i) <> 0) and (f(8, i) <> 0) and (f(9, i) <> 0) and
 | 
			
		||||
            (f(10, i) <> 0) and (f(11, i) <> 0) and (f(12, i) <> 0) and (f(13, i) <> 0) and (f(14, i) <> 0) and
 | 
			
		||||
            (f(15, i) <> 0) and (f(16, i) <> 0) and (f(17, i) <> 0) and (f(18, i) <> 0) and (f(19, i) <> 0) then
 | 
			
		||||
        ;
 | 
			
		||||
    end;
 | 
			
		||||
 | 
			
		||||
    for i := 0 to 19 do
 | 
			
		||||
    begin
 | 
			
		||||
        if (g(0, i) <> 0) or (g(1, i) <> 0) or (g(2, i) <> 0) or (g(3, i) <> 0) or (g(4, i) <> 0) or
 | 
			
		||||
            (g(5, i) <> 0) or (g(6, i) <> 0) or (g(7, i) <> 0) or (g(8, i) <> 0) or (g(9, i) <> 0) or
 | 
			
		||||
            (g(10, i) <> 0) or (g(11, i) <> 0) or (g(12, i) <> 0) or (g(13, i) <> 0) or (g(14, i) <> 0) or
 | 
			
		||||
            (g(15, i) <> 0) or (g(16, i) <> 0) or (g(17, i) <> 0) or (g(18, i) <> 0) or (g(19, i) <> 0) then
 | 
			
		||||
        ;
 | 
			
		||||
    end;
 | 
			
		||||
 | 
			
		||||
    ans := 0;
 | 
			
		||||
    if (h(0) <> 0) and (h(1) <> 0) or (not (h(2) <> 0)) or (h(3) <> 0) then
 | 
			
		||||
        ans := 1;
 | 
			
		||||
    ans := 0;
 | 
			
		||||
    if (not (h(4) <> 0)) or (h(5) <> 0) and (not (h(6) <> 0)) and (h(7) <> 0) or (not (h(8) <> 0)) then
 | 
			
		||||
        ans := 1;
 | 
			
		||||
    ans := 0;
 | 
			
		||||
    if (h(9) <> 0) and (not (h(10) <> 0)) or (not (h(11) <> 0)) or (not (h(12) <> 0)) or (not (h(13) <> 0)) or (h(14) <> 0) and (h(15) <> 0) then
 | 
			
		||||
        ans := 1;
 | 
			
		||||
    ans := 0;
 | 
			
		||||
    if (h(0) <> 0) and (h(2) <> 0) and (not (h(3) <> 0)) and (not (h(4) <> 0)) or (h(5) <> 0) or (h(6) <> 0) and (not (h(7) <> 0)) or (h(8) <> 0) then
 | 
			
		||||
        ans := 1;
 | 
			
		||||
    write(sum + ans); 
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										1
									
								
								open_set/87_long_line.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								open_set/87_long_line.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
program main;var sum, i, ans: integer;arr: array[0..19] of integer;function f(i, j: integer): integer;begin sum := sum + 1;if (i >= j) or (i >= 20) then f := 0 else begin arr[i] := 1;if i = 0 then f := arr[0]else f := arr[i - 1];end;end;function g(i,j: integer):integer;begin sum := sum + 2;if (i >= j) or (i >= 20) then g := 1 else begin arr[i] := 0;if i = 0 then g := arr[0] else g := arr[i - 1];end;end;function h(i: integer): integer;begin sum := sum + 3;if (i < 0) or (i >= 20) then h := 0 else h := arr[i];end;begin for i := 0 to 19 do arr[i] := 0;for i := 0 to 19 do begin if (f(0, i) <> 0) and (f(1, i) <> 0) and (f(2, i) <> 0) and (f(3, i) <> 0) and (f(4, i) <> 0) and (f(5, i) <> 0) and (f(6, i) <> 0) and (f(7, i) <> 0) and (f(8, i) <> 0) and (f(9, i) <> 0) and (f(10, i) <> 0) and (f(11, i) <> 0) and (f(12, i) <> 0) and (f(13, i) <> 0) and (f(14, i) <> 0) and (f(15, i) <> 0) and (f(16, i) <> 0) and (f(17, i) <> 0) and (f(18, i) <> 0) and (f(19, i) <> 0) then;end;for i := 0 to 19 do begin if (g(0, i) <> 0) or (g(1, i) <> 0) or (g(2, i) <> 0) or (g(3, i) <> 0) or (g(4, i) <> 0) or (g(5, i) <> 0) or (g(6, i) <> 0) or (g(7, i) <> 0) or (g(8, i) <> 0) or (g(9, i) <> 0) or (g(10, i) <> 0) or (g(11, i) <> 0) or (g(12, i) <> 0) or (g(13, i) <> 0) or (g(14, i) <> 0) or (g(15, i) <> 0) or (g(16, i) <> 0) or (g(17, i) <> 0) or (g(18, i) <> 0) or (g(19, i) <> 0) then ;end;ans := 0;if (h(0) <> 0) and (h(1) <> 0) or (not (h(2) <> 0)) or (h(3) <> 0) then ans := 1;ans := 0;if (not (h(4) <> 0)) or (h(5) <> 0) and (not (h(6) <> 0)) and (h(7) <> 0) or (not (h(8) <> 0)) then ans := 1;ans := 0;if (h(9) <> 0) and (not (h(10) <> 0)) or (not (h(11) <> 0)) or (not (h(12) <> 0)) or (not (h(13) <> 0)) or (h(14) <> 0) and (h(15) <> 0) then ans := 1;ans := 0;if (h(0) <> 0) and (h(2) <> 0) and (not (h(3) <> 0)) and (not (h(4) <> 0)) or (h(5) <> 0) or (h(6) <> 0) and (not (h(7) <> 0)) or (h(8) <> 0) then ans := 1;write(sum + ans); end.
 | 
			
		||||
							
								
								
									
										20
									
								
								open_set/88_many_indirections.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								open_set/88_many_indirections.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
program main;
 | 
			
		||||
const N=100;M=20;
 | 
			
		||||
var 
 | 
			
		||||
arr: array[0..99, 0..19] of integer;
 | 
			
		||||
i,j,sum:integer;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    for i := 0 to M -1 do
 | 
			
		||||
    begin
 | 
			
		||||
        for j := 0 to N - 1 do
 | 
			
		||||
        begin
 | 
			
		||||
            arr[i, j] := j;
 | 
			
		||||
        end;
 | 
			
		||||
    end;
 | 
			
		||||
    sum := arr[0, arr[1, arr[2, arr[3, arr[4, arr[5, arr[6, arr[7, arr[8,arr[9,arr[10,arr[11,arr[12,arr[13,arr[14,arr[15,arr[16,arr[17,arr[18,arr[19,19]]]]]]]]]]]]]]]]]]]] + 
 | 
			
		||||
            arr[arr[arr[arr[arr[arr[arr[arr[arr[arr[arr[arr[arr
 | 
			
		||||
                                                                                  [arr[arr[arr[arr[arr[arr[arr[19,18],
 | 
			
		||||
                                                                                                                17],16],15],14],13],12],11],10],9],8],7],6],5],4],3],2],1],0],19];
 | 
			
		||||
    write(sum);                                                                                                          
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										72
									
								
								open_set/89_many_params3.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								open_set/89_many_params3.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
program main;
 | 
			
		||||
var ret: integer;
 | 
			
		||||
 | 
			
		||||
function func(  aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,
 | 
			
		||||
                ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw,bx,by,bz,
 | 
			
		||||
                ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp,cq,cr,cs,ct,cu,cv,cw,cx,cy,cz,
 | 
			
		||||
                da,db,dc,dd,de,df,dg,dh,di,dj,dk,dl,dm,dn,doo,dp,dq,dr,ds,dt,du,dv,dw,dx,dy,dz,
 | 
			
		||||
                ea,eb,ec,ed,ee,ef,eg,eh,ei,ej,ek,el,em,en,eo,ep,eq,er,es,et,eu,ev,ew,ex,ey,ez,
 | 
			
		||||
                fa,fb,fc,fd,fe,ff,fg,fh,fi,fj,fk,fl,fm,fn,fo,fp,fq,fr,fs,ft,fu,fv,fw,fx,fy,fz,
 | 
			
		||||
                ga,gb,gc,gd,ge,gf,gg,gh,gi,gj,gk,gl,gm,gn,go,gp,gq,gr,gs,gt,gu,gv,gw,gx,gy,gz,
 | 
			
		||||
                ha,hb,hc,hd,he,hf,hg,hh,hi,hj,hk,hl,hm,hn,ho,hp,hq,hr,hs,ht,hu,hv,hw,hx,hy,hz,
 | 
			
		||||
                ia,ib,ic,id,ie,iff,ig,ih,ii,ij,ik,il,im,inn,io,ip,iq,ir,is,it,iu,iv,iw,ix,iy,iz,
 | 
			
		||||
                ja,jb,jc,jd,je,jf,jg,jh,ji,jj,jk,jl,jm,jn,jo,jp,jq,jr,js,jt,ju,jv,jw,jx,jy,jz,
 | 
			
		||||
                ka,kb,kc,kd,ke,kf,kg,kh,ki,kj,kk,kl,km,kn,ko,kp,kq,kr,ks,kt,ku,kv,kw,kx,ky,kz,
 | 
			
		||||
                la,lb,lc,ld,le,lf,lg,lh,li,lj,lk,ll,lm,ln,lo,lp,lq,lr,ls,lt,lu,lv,lw,lx,ly,lz,
 | 
			
		||||
                ma,mb,mc,md,me,mf,mg,mh,mi,mj,mk,ml,mm,mn,mo,mp,mq,mr,ms,mt,mu,mv,mw,mx,my,mz,
 | 
			
		||||
                na,nb,nc,nd,ne,nf,ng,nh,ni,nj,nk,nl,nm,nn,no,np,nq,nr,ns,nt,nu,nv,nw,nx,ny,nz,
 | 
			
		||||
                oa,ob,oc,od,oe,off,og,oh,oi,oj,ok,ol,om,on,oo,op,oq,orr,os,ot,ou,ov,ow,ox,oy,oz,
 | 
			
		||||
                pa,pb,pc,pd,pe,pf,pg,ph,pi,pj,pk,pl,pm,pn,po,pp,pq,pr,ps,pt,pu,pv,pw,px,py,pz,
 | 
			
		||||
                qa,qb,qc,qd,qe,qf,qg,qh,qi,qj,qk,ql,qm,qn,qo,qp,qq,qr,qs,qt,qu,qv,qw,qx,qy,qz,
 | 
			
		||||
                ra,rb,rc,rd,re,rf,rg,rh,ri,rj,rk,rl,rm,rn,ro,rp,rq,rr,rs,rt,ru,rv,rw,rx,ry,rz,
 | 
			
		||||
                sa,sb,sc,sd,se,sf,sg,sh,si,sj,sk,sl,sm,sn,so,sp,sq,sr,ss,st,su,sv,sw,sx,sy,sz,
 | 
			
		||||
                ta,tb,tc,td,te,tf,tg,th,ti,tj,tk,tl,tm,tn,too,tp,tq,tr,ts,tt,tu,tv,tw,tx,ty,tz,
 | 
			
		||||
                ua,ub,uc,ud,ue,uf,ug,uh,ui,uj,uk,ul,um,un,uo,up,uq,ur,us,ut,uu,uv,uw,ux,uy,uz,
 | 
			
		||||
                va,vb,vc,vd,ve,vf,vg,vh,vi,vj,vk,vl,vm,vn,vo,vp,vq,vr,vs,vt,vu,vv,vw,vx,vy,vz,
 | 
			
		||||
                wa,wb,wc,wd,we,wf,wg,wh,wi,wj,wk,wl,wm,wn,wo,wp,wq,wr,ws,wt,wu,wv,ww,wx,wy,wz,
 | 
			
		||||
                xa,xb,xc,xd,xe,xf,xg,xh,xi,xj,xk,xl,xm,xn,xo,xp,xq,xr,xs,xt,xu,xv,xw,xx,xy,xz,
 | 
			
		||||
                ya,yb,yc,yd,ye,yf,yg,yh,yi,yj,yk,yl,ym,yn,yo,yp,yq,yr,ys,yt,yu,yv,yw,yx,yy,yz,
 | 
			
		||||
                za,zb,zc,zd,ze,zf,zg,zh,zi,zj,zk,zl,zm,zn,zo,zp,zq,zr,zs,zt,zu,zv,zw,zx,zy,zz: integer): integer;
 | 
			
		||||
begin
 | 
			
		||||
    func :=     zi * xy * ve * zl * dk + ui + sd * bx * qr * kk * qk * jt * xj + wl * wg + kb + ii * vj * oa + pb * ku + ee * fv + ha + bm * jv * ka * mr + gv + qh + ci + az * lj * ie + pz * zg + js * wj * il * fx * vs + ed + te + ke + sq * hq * da + vb * gp + ab * kx * lc + pn * ae + cs * on + xe + zi + mf + sc * ak * ko + hx * ax + gc * cm + br * fl + ul + el + nt + tt * eh + gq + up * uj * kz + yj + ah * dl * xz * il * km * qp * yx + lc + re * qb + nl + on + gq + zs + ca * lh + ra + doo * op + cl * et * ad +
 | 
			
		||||
	            kb + tc + bb * oo + mg + ws * xj + ri * ty * mu + cy + dp * wm * wt + dw + pv + it + iy + it + za * hw + kx * pc * zs * ht * sv * jy + gk + cq * ym * vz * de * gg + fc * dk * yb * wm + zu + th * bn * iy * doo + al + vj * ex * di * jb * ss * bd * kn + yz + kw + tv * ug + iff * wx * fn * ul * tt * fp * hn * dv * zv * al * wr + fa * vv + ls + ia * ip * uv + li + zs + em + pa * zf + zb + bt + ad + jp +
 | 
			
		||||
	            ut + tm + et + ct + hc + en * hd * hf * cr * lm + pp * wj * nd * ka * ta + ru * jn + en + gc * jb +
 | 
			
		||||
	            kg * bf + sl + pr + uc + yv + vd * td * xg + cp * rj + qu + vw * ao * oz + zf + qj + kl * st * on * qq + mv * eu * ay * ih * ta * tm + vh + rz + yn * bp + pr + xt * lw + uo * zl * rv + fz * rz * fz +
 | 
			
		||||
		        mf * sj + xz * yt + qj + ki * gf + ne + gd + vz + oh + hh + ff + ec * xk + hb + pe + mz * yx * aw +
 | 
			
		||||
		        ij + dn + zj * nm + jj * kz * ic * sg + ue * yo + le + fg * kt * br * yx + so * qy + bd + da + iq +
 | 
			
		||||
		        go + uu + jj * le + xa + vs * qs + mq + vr + ua + hx * oz * sl * cj * hg + rd * bz + vk * ic + ib +
 | 
			
		||||
		        fj * au * dm + ve * ks + pl * oi * kd * iu + be * rr + va * hc * tl + wm + rq + ob + pg * hq + pe * ww * ei * rn + yk + oc * sh * ig * uu + cg * vu * yn + xj * wh + xf + wo + nr + vf * sa * yg + uj +
 | 
			
		||||
		        sb + dt + pn + ui + nc * bv + qa * ze * kn + zt * da + kw * xp + hy * hs + pb + ox * uz * pe + be * im + sg + tm * im + gh * ju * zx + fc + pn * ei * we + ae * re + wp * aj + pc * km * pm + hc * bt * ap * ik * am + yu + my + wh * ah * tt * fo + rx * te * al + tq + fj + df * ts + jl + lx + ov + inn;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  ret := 0;
 | 
			
		||||
  ret := func(
 | 
			
		||||
        0, 1, 1, 8, 9, 5, 2, 0, 6, 2, 4, 7, 1, 6, 9, 3, 3, 5, 0, 8, 9, 3, 4, 5, 9, 0,
 | 
			
		||||
		8, 9, 5, 5, 4, 1, 4, 3, 5, 9, 7, 6, 1, 7, 5, 4, 0, 7, 5, 5, 6, 4, 9, 6, 6, 6,
 | 
			
		||||
		8, 0, 4, 2, 3, 3, 0, 5, 4, 3, 9, 5, 9, 3, 3, 6, 4, 3, 3, 0, 5, 0, 2, 5, 6, 6,
 | 
			
		||||
		9, 4, 0, 3, 7, 2, 1, 1, 9, 8, 4, 8, 5, 2, 5, 4, 5, 0, 3, 5, 0, 7, 0, 7, 5, 6,
 | 
			
		||||
		7, 7, 8, 2, 6, 8, 9, 4, 6, 7, 2, 9, 8, 8, 0, 0, 3, 4, 8, 9, 0, 5, 9, 8, 5, 1,
 | 
			
		||||
		2, 7, 3, 2, 5, 4, 9, 9, 6, 9, 2, 5, 5, 7, 8, 3, 8, 9, 4, 9, 0, 5, 9, 8, 4, 2,
 | 
			
		||||
		5, 0, 7, 8, 8, 4, 6, 7, 9, 8, 2, 4, 4, 2, 9, 9, 8, 1, 2, 3, 7, 2, 2, 1, 7, 1,
 | 
			
		||||
		2, 4, 0, 6, 6, 0, 9, 9, 0, 7, 8, 9, 8, 5, 1, 8, 9, 2, 4, 7, 3, 4, 7, 9, 9, 4,
 | 
			
		||||
		7, 1, 9, 0, 6, 0, 6, 9, 8, 4, 3, 6, 2, 9, 7, 5, 6, 9, 8, 6, 5, 8, 4, 0, 5, 2,
 | 
			
		||||
		3, 2, 4, 0, 0, 9, 5, 8, 9, 2, 5, 2, 5, 0, 9, 4, 2, 0, 0, 1, 5, 0, 4, 9, 4, 9,
 | 
			
		||||
		4, 6, 0, 0, 4, 2, 6, 9, 3, 7, 8, 5, 5, 7, 1, 0, 5, 3, 6, 0, 3, 3, 6, 2, 9, 9,
 | 
			
		||||
		1, 9, 6, 2, 4, 1, 5, 1, 5, 0, 8, 5, 7, 9, 4, 6, 1, 3, 9, 4, 2, 3, 0, 8, 6, 0,
 | 
			
		||||
		9, 7, 3, 1, 3, 7, 0, 9, 2, 3, 1, 2, 9, 3, 8, 5, 7, 3, 9, 6, 7, 1, 9, 6, 3, 8,
 | 
			
		||||
		1, 8, 8, 2, 8, 7, 5, 4, 2, 0, 4, 0, 7, 7, 8, 9, 6, 6, 7, 7, 1, 6, 0, 5, 3, 4,
 | 
			
		||||
		2, 6, 3, 6, 3, 4, 1, 3, 6, 9, 4, 3, 0, 9, 0, 2, 2, 0, 8, 8, 4, 5, 8, 2, 3, 3,
 | 
			
		||||
		7, 2, 5, 9, 6, 7, 0, 1, 8, 5, 7, 8, 3, 0, 2, 9, 1, 5, 4, 9, 4, 5, 3, 7, 4, 0,
 | 
			
		||||
		2, 7, 1, 3, 2, 7, 1, 7, 0, 0, 6, 7, 8, 9, 0, 2, 5, 4, 6, 2, 9, 2, 1, 0, 2, 2,
 | 
			
		||||
		7, 3, 8, 9, 6, 3, 6, 9, 0, 8, 1, 2, 2, 9, 5, 8, 2, 5, 0, 4, 7, 0, 8, 2, 9, 6,
 | 
			
		||||
		7, 7, 5, 2, 6, 6, 8, 8, 9, 7, 7, 4, 9, 0, 8, 7, 6, 8, 3, 1, 6, 7, 4, 6, 5, 6,
 | 
			
		||||
		2, 8, 8, 5, 9, 0, 3, 1, 9, 1, 4, 9, 6, 4, 7, 6, 6, 8, 9, 6, 6, 1, 2, 5, 2, 0,
 | 
			
		||||
		3, 8, 2, 9, 1, 3, 9, 6, 2, 3, 2, 9, 9, 3, 8, 8, 1, 9, 8, 5, 1, 1, 2, 7, 9, 3,
 | 
			
		||||
		7, 4, 3, 4, 0, 7, 4, 9, 1, 4, 6, 4, 3, 8, 3, 8, 7, 6, 3, 2, 1, 8, 5, 2, 3, 1,
 | 
			
		||||
		3, 7, 6, 2, 4, 0, 9, 9, 7, 8, 3, 7, 5, 8, 8, 5, 6, 7, 3, 2, 9, 5, 5, 1, 5, 7,
 | 
			
		||||
		9, 7, 9, 0, 5, 4, 3, 3, 0, 0, 0, 3, 5, 1, 6, 2, 0, 4, 7, 4, 9, 7, 3, 4, 0, 6,
 | 
			
		||||
		0, 3, 1, 3, 5, 7, 3, 8, 3, 1, 9, 6, 8, 6, 7, 7, 3, 2, 9, 8, 1, 9, 5, 8, 4, 7,
 | 
			
		||||
		8, 9, 9, 0, 9, 2, 9, 0, 0, 7, 4, 3, 9, 2, 2, 7, 8, 7, 1, 3, 5, 8, 4, 4, 0, 9);
 | 
			
		||||
  write(ret);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										309
									
								
								open_set/90_multi_branch.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										309
									
								
								open_set/90_multi_branch.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,309 @@
 | 
			
		||||
program main;
 | 
			
		||||
var a,res,n,i: integer;
 | 
			
		||||
begin
 | 
			
		||||
    n := 2;
 | 
			
		||||
    for i := 0 to  n - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        res := 0;
 | 
			
		||||
        a := 1;
 | 
			
		||||
        if (a > 0) and (a < 100) then
 | 
			
		||||
			if (a > 0) and (a < 99) then
 | 
			
		||||
				if (a > 0) and (a < 98) then
 | 
			
		||||
					if (a > 0) and (a < 97) then
 | 
			
		||||
						if (a > 0) and (a < 96) then
 | 
			
		||||
							if (a > 0) and (a < 95) then
 | 
			
		||||
								if (a > 0) and (a < 94) then
 | 
			
		||||
									if (a > 0) and (a < 93) then
 | 
			
		||||
										if (a > 0) and (a < 92) then
 | 
			
		||||
											if (a > 0) and (a < 91) then
 | 
			
		||||
												if (a > 0) and (a < 90) then
 | 
			
		||||
													if (a > 0) and (a < 89) then
 | 
			
		||||
														if (a > 0) and (a < 88) then
 | 
			
		||||
															if (a > 0) and (a < 87) then
 | 
			
		||||
																if (a > 0) and (a < 86) then
 | 
			
		||||
																	if (a > 0) and (a < 85) then
 | 
			
		||||
																		if (a > 0) and (a < 84) then
 | 
			
		||||
																			if (a > 0) and (a < 83) then
 | 
			
		||||
																				if (a > 0) and (a < 82) then
 | 
			
		||||
																					if (a > 0) and (a < 81) then
 | 
			
		||||
																						if (a > 0) and (a < 80) then
 | 
			
		||||
																							if (a > 0) and (a < 79) then
 | 
			
		||||
																								if (a > 0) and (a < 78) then
 | 
			
		||||
																									if (a > 0) and (a < 77) then
 | 
			
		||||
																										if (a > 0) and (a < 76) then
 | 
			
		||||
																											if (a > 0) and (a < 75) then
 | 
			
		||||
																												if (a > 0) and (a < 74) then
 | 
			
		||||
																													if (a > 0) and (a < 73) then
 | 
			
		||||
																														if (a > 0) and (a < 72) then
 | 
			
		||||
																															if (a > 0) and (a < 71) then
 | 
			
		||||
																																if (a > 0) and (a < 70) then
 | 
			
		||||
																																	if (a > 0) and (a < 69) then
 | 
			
		||||
																																		if (a > 0) and (a < 68) then
 | 
			
		||||
																																			if (a > 0) and (a < 67) then
 | 
			
		||||
																																				if (a > 0) and (a < 66) then
 | 
			
		||||
																																					if (a > 0) and (a < 65) then
 | 
			
		||||
																																						if (a > 0) and (a < 64) then
 | 
			
		||||
																																							if (a > 0) and (a < 63) then
 | 
			
		||||
																																								if (a > 0) and (a < 62) then
 | 
			
		||||
																																									if (a > 0) and (a < 61) then
 | 
			
		||||
																																										if (a > 0) and (a < 60) then
 | 
			
		||||
																																											if (a > 0) and (a < 59) then
 | 
			
		||||
																																												if (a > 0) and (a < 58) then
 | 
			
		||||
																																													if (a > 0) and (a < 57) then
 | 
			
		||||
																																														if (a > 0) and (a < 56) then
 | 
			
		||||
																																															if (a > 0) and (a < 55) then
 | 
			
		||||
																																																if (a > 0) and (a < 54) then
 | 
			
		||||
																																																	if (a > 0) and (a < 53) then
 | 
			
		||||
																																																		if (a > 0) and (a < 52) then
 | 
			
		||||
																																																			if (a > 0) and (a < 51) then
 | 
			
		||||
																																																				if (a > 0) and (a < 50) then
 | 
			
		||||
																																																					if (a > 0) and (a < 49) then
 | 
			
		||||
																																																						if (a > 0) and (a < 48) then
 | 
			
		||||
																																																							if (a > 0) and (a < 47) then
 | 
			
		||||
																																																								if (a > 0) and (a < 46) then
 | 
			
		||||
																																																									if (a > 0) and (a < 45) then
 | 
			
		||||
																																																										if (a > 0) and (a < 44) then
 | 
			
		||||
																																																											if (a > 0) and (a < 43) then
 | 
			
		||||
																																																												if (a > 0) and (a < 42) then
 | 
			
		||||
																																																													if (a > 0) and (a < 41) then
 | 
			
		||||
																																																														if (a > 0) and (a < 40) then
 | 
			
		||||
																																																															if (a > 0) and (a < 39) then
 | 
			
		||||
																																																																if (a > 0) and (a < 38) then
 | 
			
		||||
																																																																	if (a > 0) and (a < 37) then
 | 
			
		||||
																																																																		if (a > 0) and (a < 36) then
 | 
			
		||||
																																																																			if (a > 0) and (a < 35) then
 | 
			
		||||
																																																																				if (a > 0) and (a < 34) then
 | 
			
		||||
																																																																					if (a > 0) and (a < 33) then
 | 
			
		||||
																																																																						if (a > 0) and (a < 32) then
 | 
			
		||||
																																																																							if (a > 0) and (a < 31) then
 | 
			
		||||
																																																																								if (a > 0) and (a < 30) then
 | 
			
		||||
																																																																									if (a > 0) and (a < 29) then
 | 
			
		||||
																																																																										if (a > 0) and (a < 28) then
 | 
			
		||||
																																																																											if (a > 0) and (a < 27) then
 | 
			
		||||
																																																																												if (a > 0) and (a < 26) then
 | 
			
		||||
																																																																													if (a > 0) and (a < 25) then
 | 
			
		||||
																																																																														if (a > 0) and (a < 24) then
 | 
			
		||||
																																																																															if (a > 0) and (a < 23) then
 | 
			
		||||
																																																																																if (a > 0) and (a < 22) then
 | 
			
		||||
																																																																																	if (a > 0) and (a < 21) then
 | 
			
		||||
																																																																																		if (a > 0) and (a < 20) then
 | 
			
		||||
																																																																																			if (a > 0) and (a < 19) then
 | 
			
		||||
																																																																																				if (a > 0) and (a < 18) then
 | 
			
		||||
																																																																																					if (a > 0) and (a < 17) then
 | 
			
		||||
																																																																																						if (a > 0) and (a < 16) then
 | 
			
		||||
																																																																																							if (a > 0) and (a < 15) then
 | 
			
		||||
																																																																																								if (a > 0) and (a < 14) then
 | 
			
		||||
																																																																																									if (a > 0) and (a < 13) then
 | 
			
		||||
																																																																																										if (a > 0) and (a < 12) then
 | 
			
		||||
																																																																																											if (a > 0) and (a < 11) then
 | 
			
		||||
																																																																																												if (a > 0) and (a < 10) then
 | 
			
		||||
																																																																																													if (a > 0) and (a < 9) then
 | 
			
		||||
																																																																																														if (a > 0) and (a < 8) then
 | 
			
		||||
																																																																																															if (a > 0) and (a < 7) then
 | 
			
		||||
																																																																																																if (a > 0) and (a < 6) then
 | 
			
		||||
																																																																																																	if (a > 0) and (a < 5) then
 | 
			
		||||
																																																																																																		if (a > 0) and (a < 4) then
 | 
			
		||||
																																																																																																			if (a > 0) and (a < 3) then
 | 
			
		||||
																																																																																																				if (a > 0) and (a < 2) then
 | 
			
		||||
																																																																																																					res := res + 1
 | 
			
		||||
																																																																																																				else
 | 
			
		||||
																																																																																																					res := res + 2
 | 
			
		||||
																																																																																																			else
 | 
			
		||||
																																																																																																				res := res + 3
 | 
			
		||||
																																																																																																		else
 | 
			
		||||
																																																																																																			res := res + 4
 | 
			
		||||
																																																																																																	else
 | 
			
		||||
																																																																																																		res := res + 5
 | 
			
		||||
																																																																																																else
 | 
			
		||||
																																																																																																	res := res + 6
 | 
			
		||||
																																																																																															else
 | 
			
		||||
																																																																																																res := res + 7
 | 
			
		||||
																																																																																														else
 | 
			
		||||
																																																																																															res := res + 8
 | 
			
		||||
																																																																																													else
 | 
			
		||||
																																																																																														res := res + 9
 | 
			
		||||
																																																																																												else
 | 
			
		||||
																																																																																													res := res + 10
 | 
			
		||||
																																																																																											else
 | 
			
		||||
																																																																																												res := res + 11
 | 
			
		||||
																																																																																										else
 | 
			
		||||
																																																																																											res := res + 12
 | 
			
		||||
																																																																																									else
 | 
			
		||||
																																																																																										res := res + 13
 | 
			
		||||
																																																																																								else
 | 
			
		||||
																																																																																									res := res + 14
 | 
			
		||||
																																																																																							else
 | 
			
		||||
																																																																																								res := res + 15
 | 
			
		||||
																																																																																						else
 | 
			
		||||
																																																																																							res := res + 16
 | 
			
		||||
																																																																																					else
 | 
			
		||||
																																																																																						res := res + 17
 | 
			
		||||
																																																																																				else
 | 
			
		||||
																																																																																					res := res + 18
 | 
			
		||||
																																																																																			else
 | 
			
		||||
																																																																																				res := res + 19
 | 
			
		||||
																																																																																		else
 | 
			
		||||
																																																																																			res := res + 20
 | 
			
		||||
																																																																																	else
 | 
			
		||||
																																																																																		res := res + 21
 | 
			
		||||
																																																																																else
 | 
			
		||||
																																																																																	res := res + 22
 | 
			
		||||
																																																																															else
 | 
			
		||||
																																																																																res := res + 23
 | 
			
		||||
																																																																														else
 | 
			
		||||
																																																																															res := res + 24
 | 
			
		||||
																																																																													else
 | 
			
		||||
																																																																														res := res + 25
 | 
			
		||||
																																																																												else
 | 
			
		||||
																																																																													res := res + 26
 | 
			
		||||
																																																																											else
 | 
			
		||||
																																																																												res := res + 27
 | 
			
		||||
																																																																										else
 | 
			
		||||
																																																																											res := res + 28
 | 
			
		||||
																																																																									else
 | 
			
		||||
																																																																										res := res + 29
 | 
			
		||||
																																																																								else
 | 
			
		||||
																																																																									res := res + 30
 | 
			
		||||
																																																																							else
 | 
			
		||||
																																																																								res := res + 31
 | 
			
		||||
																																																																						else
 | 
			
		||||
																																																																							res := res + 32
 | 
			
		||||
																																																																					else
 | 
			
		||||
																																																																						res := res + 33
 | 
			
		||||
																																																																				else
 | 
			
		||||
																																																																					res := res + 34
 | 
			
		||||
																																																																			else
 | 
			
		||||
																																																																				res := res + 35
 | 
			
		||||
																																																																		else
 | 
			
		||||
																																																																			res := res + 36
 | 
			
		||||
																																																																	else
 | 
			
		||||
																																																																		res := res + 37
 | 
			
		||||
																																																																else
 | 
			
		||||
																																																																	res := res + 38
 | 
			
		||||
																																																															else
 | 
			
		||||
																																																																res := res + 39
 | 
			
		||||
																																																														else
 | 
			
		||||
																																																															res := res + 40
 | 
			
		||||
																																																													else
 | 
			
		||||
																																																														res := res + 41
 | 
			
		||||
																																																												else
 | 
			
		||||
																																																													res := res + 42
 | 
			
		||||
																																																											else
 | 
			
		||||
																																																												res := res + 43
 | 
			
		||||
																																																										else
 | 
			
		||||
																																																											res := res + 44
 | 
			
		||||
																																																									else
 | 
			
		||||
																																																										res := res + 45
 | 
			
		||||
																																																								else
 | 
			
		||||
																																																									res := res + 46
 | 
			
		||||
																																																							else
 | 
			
		||||
																																																								res := res + 47
 | 
			
		||||
																																																						else
 | 
			
		||||
																																																							res := res + 48
 | 
			
		||||
																																																					else
 | 
			
		||||
																																																						res := res + 49
 | 
			
		||||
																																																				else
 | 
			
		||||
																																																					res := res + 50
 | 
			
		||||
																																																			else
 | 
			
		||||
																																																				res := res + 51
 | 
			
		||||
																																																		else
 | 
			
		||||
																																																			res := res + 52
 | 
			
		||||
																																																	else
 | 
			
		||||
																																																		res := res + 53
 | 
			
		||||
																																																else
 | 
			
		||||
																																																	res := res + 54
 | 
			
		||||
																																															else
 | 
			
		||||
																																																res := res + 55
 | 
			
		||||
																																														else
 | 
			
		||||
																																															res := res + 56
 | 
			
		||||
																																													else
 | 
			
		||||
																																														res := res + 57
 | 
			
		||||
																																												else
 | 
			
		||||
																																													res := res + 58
 | 
			
		||||
																																											else
 | 
			
		||||
																																												res := res + 59
 | 
			
		||||
																																										else
 | 
			
		||||
																																											res := res + 60
 | 
			
		||||
																																									else
 | 
			
		||||
																																										res := res + 61
 | 
			
		||||
																																								else
 | 
			
		||||
																																									res := res + 62
 | 
			
		||||
																																							else
 | 
			
		||||
																																								res := res + 63
 | 
			
		||||
																																						else
 | 
			
		||||
																																							res := res + 64
 | 
			
		||||
																																					else
 | 
			
		||||
																																						res := res + 65
 | 
			
		||||
																																				else
 | 
			
		||||
																																					res := res + 66
 | 
			
		||||
																																			else
 | 
			
		||||
																																				res := res + 67
 | 
			
		||||
																																		else
 | 
			
		||||
																																			res := res + 68
 | 
			
		||||
																																	else
 | 
			
		||||
																																		res := res + 69
 | 
			
		||||
																																else
 | 
			
		||||
																																	res := res + 70
 | 
			
		||||
																															else
 | 
			
		||||
																																res := res + 71
 | 
			
		||||
																														else
 | 
			
		||||
																															res := res + 72
 | 
			
		||||
																													else
 | 
			
		||||
																														res := res + 73
 | 
			
		||||
																												else
 | 
			
		||||
																													res := res + 74
 | 
			
		||||
																											else
 | 
			
		||||
																												res := res + 75
 | 
			
		||||
																										else
 | 
			
		||||
																											res := res + 76
 | 
			
		||||
																									else
 | 
			
		||||
																										res := res + 77
 | 
			
		||||
																								else
 | 
			
		||||
																									res := res + 78
 | 
			
		||||
																							else
 | 
			
		||||
																								res := res + 79
 | 
			
		||||
																						else
 | 
			
		||||
																							res := res + 80
 | 
			
		||||
																					else
 | 
			
		||||
																						res := res + 81
 | 
			
		||||
																				else
 | 
			
		||||
																					res := res + 82
 | 
			
		||||
																			else
 | 
			
		||||
																				res := res + 83
 | 
			
		||||
																		else
 | 
			
		||||
																			res := res + 84
 | 
			
		||||
																	else
 | 
			
		||||
																		res := res + 85
 | 
			
		||||
																else
 | 
			
		||||
																	res := res + 86
 | 
			
		||||
															else
 | 
			
		||||
																res := res + 87
 | 
			
		||||
														else
 | 
			
		||||
															res := res + 88
 | 
			
		||||
													else
 | 
			
		||||
														res := res + 89
 | 
			
		||||
												else
 | 
			
		||||
													res := res + 90
 | 
			
		||||
											else
 | 
			
		||||
												res := res + 91
 | 
			
		||||
										else
 | 
			
		||||
											res := res + 92
 | 
			
		||||
									else
 | 
			
		||||
										res := res + 93
 | 
			
		||||
								else
 | 
			
		||||
									res := res + 94
 | 
			
		||||
							else
 | 
			
		||||
								res := res + 95
 | 
			
		||||
						else
 | 
			
		||||
							res := res + 96
 | 
			
		||||
					else
 | 
			
		||||
						res := res + 97
 | 
			
		||||
				else
 | 
			
		||||
					res := res + 98
 | 
			
		||||
			else
 | 
			
		||||
				res := res + 99
 | 
			
		||||
		else
 | 
			
		||||
			res := res + 100;
 | 
			
		||||
        write(res);
 | 
			
		||||
    end;
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										54
									
								
								open_set/91_multi_loop.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								open_set/91_multi_loop.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
program NestedLoops;
 | 
			
		||||
var
 | 
			
		||||
  a, i, j, k, ii, jj, kk, iii, jjj, kkk, iiii, jjjj, kkkk, iiiii, jjjjj, kkkkk: integer;
 | 
			
		||||
begin
 | 
			
		||||
  a := 0;
 | 
			
		||||
  for i := 0 to 2 do
 | 
			
		||||
  begin
 | 
			
		||||
    for j := 0 to 3 do
 | 
			
		||||
    begin
 | 
			
		||||
      for k := 0 to 4 do
 | 
			
		||||
      begin
 | 
			
		||||
        for ii := 0 to 2 do
 | 
			
		||||
        begin
 | 
			
		||||
          for jj := 0 to 4 do
 | 
			
		||||
          begin
 | 
			
		||||
            for kk := 0 to 3 do
 | 
			
		||||
            begin
 | 
			
		||||
              for iii := 0 to 5 do
 | 
			
		||||
              begin
 | 
			
		||||
                for jjj := 0 to 4 do
 | 
			
		||||
                begin
 | 
			
		||||
                  for kkk := 0 to 4 do
 | 
			
		||||
                  begin
 | 
			
		||||
                    for iiii := 0 to 2 do
 | 
			
		||||
                    begin
 | 
			
		||||
                      for jjjj := 0 to 5 do
 | 
			
		||||
                      begin
 | 
			
		||||
                        for kkkk := 0 to 6 do
 | 
			
		||||
                        begin
 | 
			
		||||
                          for iiiii := 0 to 4 do
 | 
			
		||||
                          begin
 | 
			
		||||
                            for jjjjj := 0 to 2 do
 | 
			
		||||
                            begin
 | 
			
		||||
                              for kkkkk := 0 to 5 do
 | 
			
		||||
                              begin
 | 
			
		||||
                                a := (a + 3) mod 999;
 | 
			
		||||
                              end;
 | 
			
		||||
                            end;
 | 
			
		||||
                          end;
 | 
			
		||||
                        end;
 | 
			
		||||
                      end;
 | 
			
		||||
                    end;
 | 
			
		||||
                  end;
 | 
			
		||||
                end;
 | 
			
		||||
              end;
 | 
			
		||||
            end;
 | 
			
		||||
          end;
 | 
			
		||||
        end;
 | 
			
		||||
      end;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  write(a);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										1
									
								
								open_set/92_math.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								open_set/92_math.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
2.0 3.0 5.5 6.6
 | 
			
		||||
							
								
								
									
										163
									
								
								open_set/92_math.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								open_set/92_math.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,163 @@
 | 
			
		||||
program main;
 | 
			
		||||
const e = 2.1718281828459045;
 | 
			
		||||
split = '--';
 | 
			
		||||
var
 | 
			
		||||
x,y:real;
 | 
			
		||||
num,i:integer;
 | 
			
		||||
 | 
			
		||||
function my_fabs(x: real):real;
 | 
			
		||||
begin
 | 
			
		||||
    if x > 0 then
 | 
			
		||||
        my_fabs := x
 | 
			
		||||
    else
 | 
			
		||||
        my_fabs := -x;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_pow(a:real; n: integer):real;
 | 
			
		||||
var i:integer; res: real;
 | 
			
		||||
begin
 | 
			
		||||
    if n < 0 then
 | 
			
		||||
        my_pow := 1 / (my_pow(a, -n))
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
        res := 1.0;
 | 
			
		||||
        for i := 0 to n - 1 do
 | 
			
		||||
            res := res * a;
 | 
			
		||||
        my_pow := res;
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_sqrt(x:real):real;
 | 
			
		||||
var t:real; c:integer;
 | 
			
		||||
begin
 | 
			
		||||
    if x > 100 then
 | 
			
		||||
        my_sqrt := 10.0 * my_sqrt(x / 100)
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
        t := x / 8 + 0.5 + 2 * x / (4 + x);
 | 
			
		||||
        for c := 0 to 9 do
 | 
			
		||||
            t := (t + x / t) / 2;
 | 
			
		||||
        my_sqrt := t;
 | 
			
		||||
    end
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function F1(x:real):real;
 | 
			
		||||
begin
 | 
			
		||||
    F1 := 1 / x;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function F2(x:real):real;
 | 
			
		||||
begin
 | 
			
		||||
    F2 := 1 / my_sqrt(1 - x * x);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function simpson(a,b: real; flag: integer): real;
 | 
			
		||||
var c:real;
 | 
			
		||||
begin
 | 
			
		||||
    c := a + (b - a) / 2;
 | 
			
		||||
    simpson := 0;
 | 
			
		||||
    if flag = 1 then
 | 
			
		||||
        simpson := (F1(a) + 4 * F1(c) + F1(b)) * (b - a) / 6
 | 
			
		||||
    else
 | 
			
		||||
        simpson := (F2(a) + 4 * F2(c) + F2(b)) * (b - a) / 6;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function asr5(a,b,eps,AA: real; flag:integer):real;
 | 
			
		||||
var c,L,R:real;
 | 
			
		||||
begin
 | 
			
		||||
    c := a + (b - a) / 2;
 | 
			
		||||
    L := simpson(a, c, flag);
 | 
			
		||||
    R := simpson(c, b, flag);
 | 
			
		||||
    if my_fabs(L + R - AA) <= (15 * eps) then
 | 
			
		||||
        asr5 := L + R + (L + R - AA) / 15.0
 | 
			
		||||
    else
 | 
			
		||||
        asr5 := asr5(a, c, eps/2, L, flag) + asr5(c, b, eps/2, R, flag);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function asr4(a,b,eps:real; flag: integer):real;
 | 
			
		||||
begin
 | 
			
		||||
    asr4 := asr5(a, b, eps, simpson(a, b, flag), flag);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function eee(x:real):real;
 | 
			
		||||
var ee: real;
 | 
			
		||||
begin
 | 
			
		||||
    if x > 0.001 then
 | 
			
		||||
    begin
 | 
			
		||||
        ee := eee(x / 2);
 | 
			
		||||
        eee := ee * ee;
 | 
			
		||||
    end
 | 
			
		||||
    else
 | 
			
		||||
        eee := 1 + x + x * x / 2 + my_pow(x, 3) / 6 + my_pow(x, 4) / 24 + my_pow(x, 5) / 120;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_exp(x:real):real;
 | 
			
		||||
var e1,e2: real; n: integer;
 | 
			
		||||
begin
 | 
			
		||||
    if x < 0 then
 | 
			
		||||
        my_exp := 1 / my_exp(-x)
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
    //pascal no cut the integer part and float part
 | 
			
		||||
        n := 1;
 | 
			
		||||
        x := x - 1.0;
 | 
			
		||||
        e1 := my_pow(e, n);
 | 
			
		||||
        e2 := eee(x);
 | 
			
		||||
        my_exp := e1 * e2;
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_ln(x:real):real;
 | 
			
		||||
begin
 | 
			
		||||
    my_ln := asr4(1, x, 0.00000001, 1);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_log(a,N: real):real;
 | 
			
		||||
begin
 | 
			
		||||
    my_log := my_ln(N) / my_ln(a);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_powf(a,x:real):real;
 | 
			
		||||
begin
 | 
			
		||||
    my_powf := my_exp(x * my_ln(a));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure putfloat(f:real);
 | 
			
		||||
begin
 | 
			
		||||
    write(f);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function getfloat():real;
 | 
			
		||||
begin
 | 
			
		||||
    read(getfloat);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    num := 2;
 | 
			
		||||
    for i := 0 to num - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
        x := getfloat;
 | 
			
		||||
        y := getfloat;
 | 
			
		||||
        putfloat(my_fabs(x));
 | 
			
		||||
        putfloat(my_pow(x, 2));
 | 
			
		||||
        putfloat(my_sqrt(x));
 | 
			
		||||
        putfloat(my_exp(x));
 | 
			
		||||
 | 
			
		||||
        if x > 0.0 then
 | 
			
		||||
            putfloat(my_ln(x))
 | 
			
		||||
        else
 | 
			
		||||
            write(split);
 | 
			
		||||
 | 
			
		||||
        if (x > 0.0) and (y > 0.0) then
 | 
			
		||||
            putfloat(my_log(x, y))
 | 
			
		||||
        else
 | 
			
		||||
            write(split);
 | 
			
		||||
        
 | 
			
		||||
        if x > 0.0 then
 | 
			
		||||
            putfloat(my_powf(x, y))
 | 
			
		||||
        else
 | 
			
		||||
            write(split);
 | 
			
		||||
    end;
 | 
			
		||||
    read(num);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										4
									
								
								open_set/93_dct.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								open_set/93_dct.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
3 3
 | 
			
		||||
1.01 2.02 3.03
 | 
			
		||||
2.02 3.03 1.01
 | 
			
		||||
3.03 2.02 1.01
 | 
			
		||||
							
								
								
									
										127
									
								
								open_set/93_dct.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								open_set/93_dct.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,127 @@
 | 
			
		||||
program main;
 | 
			
		||||
const
 | 
			
		||||
PI = 3.14159265359;
 | 
			
		||||
TWO_PI = 6.28318530718;
 | 
			
		||||
EPSILON = 0.000001;
 | 
			
		||||
var
 | 
			
		||||
test_block, test_dct, test_idct: array [0..7, 0..7] of real;
 | 
			
		||||
dim_x, dim_y, i, j: integer;
 | 
			
		||||
 | 
			
		||||
function my_fabs(x: real): real;
 | 
			
		||||
begin
 | 
			
		||||
  if x > 0.0 then
 | 
			
		||||
    my_fabs := x
 | 
			
		||||
  else
 | 
			
		||||
    my_fabs := -x;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function p(x: real):  real;
 | 
			
		||||
begin
 | 
			
		||||
  p := 3 * x - 4 * x * x * x;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_sin_impl(x: real): real;
 | 
			
		||||
begin
 | 
			
		||||
  if my_fabs(x) <= EPSILON then
 | 
			
		||||
    my_sin_impl := x
 | 
			
		||||
  else
 | 
			
		||||
    my_sin_impl := p(my_sin_impl(x / 3.0));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_sin(x: real): real;
 | 
			
		||||
var xx: integer;
 | 
			
		||||
begin
 | 
			
		||||
  if (x > TWO_PI) or (x < -TWO_PI) then
 | 
			
		||||
  begin
 | 
			
		||||
    xx := 1;
 | 
			
		||||
    x := x - 1.0;
 | 
			
		||||
  end;
 | 
			
		||||
  if x > PI then
 | 
			
		||||
    x := x - TWO_PI;
 | 
			
		||||
  if x < -PI then
 | 
			
		||||
    x := x + TWO_PI;
 | 
			
		||||
  my_sin := my_sin_impl(x);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function my_cos(x: real): real;
 | 
			
		||||
begin
 | 
			
		||||
  my_cos := my_sin(x * PI / 2);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure write_mat(n, m: integer);
 | 
			
		||||
var i,j: integer;
 | 
			
		||||
begin
 | 
			
		||||
  for i := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    write(test_dct[i, 0]);
 | 
			
		||||
    for j := 1 to m - 1 do
 | 
			
		||||
      write(test_dct[i, j]);
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure write_mat2(n, m: integer);
 | 
			
		||||
var i,j: integer;
 | 
			
		||||
begin
 | 
			
		||||
  for i := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    write(test_idct[i, 0]);
 | 
			
		||||
    for j := 1 to m - 1 do
 | 
			
		||||
      write(test_idct[i, j]);
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure dct(n, m: integer);
 | 
			
		||||
var u, v, i, j: integer;
 | 
			
		||||
begin
 | 
			
		||||
  for u := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for v := 0 to m - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
      test_dct[u, v] := 0;
 | 
			
		||||
      for i := 0 to n - 1 do
 | 
			
		||||
      begin
 | 
			
		||||
        for j := 0 to m - 1 do
 | 
			
		||||
        begin
 | 
			
		||||
          test_dct[u, v] := test_dct[u, v] + test_block[i, j] * my_cos(PI / n * (i + 1.0 / 2.0) * u) * my_cos(PI / m * (i + 1.0 / 2.0) * v);
 | 
			
		||||
        end;
 | 
			
		||||
      end;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure idct(n, m: integer);
 | 
			
		||||
var u, v, i, j: integer;
 | 
			
		||||
begin
 | 
			
		||||
  for u := 0 to n - 1 do
 | 
			
		||||
  begin
 | 
			
		||||
    for v := 0 to m - 1 do
 | 
			
		||||
    begin
 | 
			
		||||
      test_idct[u, v] := 1 / 4.0 * test_dct[0, 0];
 | 
			
		||||
      for i := 1 to n - 1 do
 | 
			
		||||
        test_idct[u, v] := test_idct[u, v] + 1 / 2.0 * test_dct[i, 0];
 | 
			
		||||
      for j := 1 to m - 1 do
 | 
			
		||||
        test_idct[u, v] := test_idct[u, v] + 1 / 2.0 * test_dct[0, j];
 | 
			
		||||
      for i := 1 to n - 1 do
 | 
			
		||||
        for j := 1 to m - 1 do
 | 
			
		||||
          test_idct[u, v] := test_idct[u, v] + test_dct[i, j] * my_cos(PI / n * (u + 1.0 / 2.0) * i) * my_cos(PI / m * (v + 1.0 / 2.0) * j);
 | 
			
		||||
      test_idct[u, v] := test_idct[u, v] * 2.0 / n * 2.0 / m;
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  dim_x := 0;
 | 
			
		||||
  dim_y := 0;
 | 
			
		||||
  read(dim_x);
 | 
			
		||||
  read(dim_y);
 | 
			
		||||
 | 
			
		||||
  for i := 0 to dim_x - 1 do
 | 
			
		||||
    for j := 0 to dim_y - 1 do
 | 
			
		||||
      read(test_block[i, j]);
 | 
			
		||||
  
 | 
			
		||||
  dct(dim_x, dim_y);
 | 
			
		||||
  write_mat(dim_x, dim_y);
 | 
			
		||||
 | 
			
		||||
  idct(dim_x, dim_y);
 | 
			
		||||
  write_mat2(dim_x, dim_y);
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										126
									
								
								open_set/94_fp_params.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								open_set/94_fp_params.pas
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,126 @@
 | 
			
		||||
program main;
 | 
			
		||||
var
 | 
			
		||||
k: integer;
 | 
			
		||||
i,j: integer;
 | 
			
		||||
ret0, ret1: real;
 | 
			
		||||
arr: array[0..39, 0..2] of real;
 | 
			
		||||
arr2: array[0..23, 0..2] of integer;
 | 
			
		||||
 | 
			
		||||
function params_f40(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13,
 | 
			
		||||
                    x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24,
 | 
			
		||||
                    x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35,
 | 
			
		||||
                    x36, x37, x38, x39: real): real;
 | 
			
		||||
var
 | 
			
		||||
i: integer;
 | 
			
		||||
arr: array[0..9] of real;
 | 
			
		||||
begin
 | 
			
		||||
    if x39 <> 0 then
 | 
			
		||||
    begin
 | 
			
		||||
        arr[0] := x0+x1+x2+x3;
 | 
			
		||||
        arr[1] := x4+x5+x6+X7;
 | 
			
		||||
        arr[2] := x8+x9+x10+x11;
 | 
			
		||||
        arr[3] := x12+x13+x14+x15;
 | 
			
		||||
        arr[4] := x16+x17+x18+x19;
 | 
			
		||||
        arr[5] := x20+x21+x22+x23;
 | 
			
		||||
        arr[6] := x24+x25+x26+x27;
 | 
			
		||||
        arr[7] := x28+x29+x30+x31;
 | 
			
		||||
        arr[8] := x32+x33+x34+x35;
 | 
			
		||||
        arr[9] := x36+x37+x38+x39;
 | 
			
		||||
        for i :=  0 to 9 do
 | 
			
		||||
            write(arr[i]);
 | 
			
		||||
        params_f40 := arr[k];
 | 
			
		||||
    end
 | 
			
		||||
    else
 | 
			
		||||
    begin
 | 
			
		||||
        params_f40 := params_f40(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13,
 | 
			
		||||
                      x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24,
 | 
			
		||||
                      x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35,
 | 
			
		||||
                      x36, x37, x38, x39, x0 + x1 + x2);
 | 
			
		||||
    end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function params_f40_i24(i23, i2, i6: integer; x4: real; i1, i4, i5: integer;
 | 
			
		||||
                        x8, x15, x7: real; i22: integer; x3: real;
 | 
			
		||||
                        x28: real; i0: integer; x37: real; i19: integer; x30: real;
 | 
			
		||||
                        x12, x1, x11, x38, x6: real; i7: integer; x32: real; i10, i13: integer;
 | 
			
		||||
                        x20, x33, x23, x9, x25: real; i8: integer; x39: real; i17: integer;
 | 
			
		||||
                        x21, x16, x5, x34: real; i18, i9: integer; x14, x10, x0: real;
 | 
			
		||||
                        i12: integer; x31: real; i11, i16: integer; x27, x24, x13, x29: real;
 | 
			
		||||
                        i3, i21, i20: integer; x18, x19, x22, x26, x36, x17: real;
 | 
			
		||||
                        i15: integer; x2: real; i14: integer; x35: real): real;
 | 
			
		||||
var
 | 
			
		||||
i : integer;
 | 
			
		||||
arr : array[0..9] of real;
 | 
			
		||||
arr2: array[0..7] of real;
 | 
			
		||||
begin
 | 
			
		||||
    if i23 <> 0 then
 | 
			
		||||
    begin
 | 
			
		||||
        arr[0] := x0+x1+x2+x3;
 | 
			
		||||
        arr[1] := x4+x5+x6+X7;
 | 
			
		||||
        arr[2] := x8+x9+x10+x11;
 | 
			
		||||
        arr[3] := x12+x13+x14+x15;
 | 
			
		||||
        arr[4] := x16+x17+x18+x19;
 | 
			
		||||
        arr[5] := x20+x21+x22+x23;
 | 
			
		||||
        arr[6] := x24+x25+x26+x27;
 | 
			
		||||
        arr[7] := x28+x29+x30+x31;
 | 
			
		||||
        arr[8] := x32+x33+x34+x35;
 | 
			
		||||
        arr[9] := x36+x37+x38+x39;
 | 
			
		||||
        arr2[0] := (i0 + i1 + i2) * 1.0;
 | 
			
		||||
        arr2[1] := (i3 + i4 + i5) * 1.0;
 | 
			
		||||
        arr2[2] := (i6 + i7 + i8) * 1.0;
 | 
			
		||||
        arr2[3] := (i9 + i10 + i11) * 1.0;
 | 
			
		||||
        arr2[4] := (i12 + i13 + i14) * 1.0;
 | 
			
		||||
        arr2[5] := (i15 + i16 + i17) * 1.0;
 | 
			
		||||
        arr2[6] := (i18 + i19 + i20) * 1.0;
 | 
			
		||||
        arr2[7] := (i21 + i22 + i23) * 1.0;
 | 
			
		||||
        for i :=  0 to 9 do
 | 
			
		||||
            write(arr[i]);
 | 
			
		||||
        for i :=  0 to 7 do
 | 
			
		||||
            write(arr2[i]);
 | 
			
		||||
        for i :=  0 to 7 do
 | 
			
		||||
            arr2[i] := arr2[i] - arr[i];
 | 
			
		||||
        params_f40_i24 := arr2[k];
 | 
			
		||||
    end
 | 
			
		||||
    else
 | 
			
		||||
        params_f40_i24 := params_f40_i24(i1, i2, i6, x4, i1, i4, i5, x8, x15, x7, i22, x3, x28,
 | 
			
		||||
                          i0, x37, i19, x30, x12, x1, x11, x38, x6, i7, x32,
 | 
			
		||||
                          i10, i13, x20, x33, x23, x9, x25, i8, x39, i17, x21,
 | 
			
		||||
                          x16, x5, x34, i18, i9, x14, x10, x0, i12, x31, i11,
 | 
			
		||||
                          i16, x27, x24, x13, x29, i3, i21, i20, x18, x19, x22,
 | 
			
		||||
                          x26, x36, x17, i15, x2, i14, x35);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
    k := 0;
 | 
			
		||||
    for i := 0 to 23 do
 | 
			
		||||
        for j := 0 to 2 do
 | 
			
		||||
            arr2[i ,j] := i * 2 - j * 3;
 | 
			
		||||
    for i := 0 to 39 do
 | 
			
		||||
        for j := 0 to 2 do
 | 
			
		||||
            arr[i, j] := i * 2.2 - j * 3.3;
 | 
			
		||||
    
 | 
			
		||||
    ret0 := params_f40(
 | 
			
		||||
      arr[0][k], arr[1][k], arr[2][k], arr[3][k], arr[4][k], arr[5][k],
 | 
			
		||||
      arr[6][k], arr[7][k], arr[8][k], arr[9][k], arr[10][k], arr[11][k],
 | 
			
		||||
      arr[12][k], arr[13][k], arr[14][k], arr[15][k], arr[16][k], arr[17][k],
 | 
			
		||||
      arr[18][k], arr[19][k], arr[20][k], arr[21][k], arr[22][k], arr[23][k],
 | 
			
		||||
      arr[24][k], arr[25][k], arr[26][k], arr[27][k], arr[28][k], arr[29][k],
 | 
			
		||||
      arr[30][k], arr[31][k], arr[32][k], arr[33][k], arr[34][k], arr[35][k],
 | 
			
		||||
      arr[36][k], arr[37][k], arr[38][k], arr[39][k]);
 | 
			
		||||
 | 
			
		||||
    ret1 := params_f40_i24(
 | 
			
		||||
      arr2[23][k], arr2[2][k], arr2[6][k], arr[4][k], arr2[1][k], arr2[4][k],
 | 
			
		||||
      arr2[5][k], arr[8][k], arr[15][k], arr[7][k], arr2[22][k], arr[3][k],
 | 
			
		||||
      arr[28][k], arr2[0][k], arr[37][k], arr2[19][k], arr[30][k], arr[12][k],
 | 
			
		||||
      arr[1][k], arr[11][k], arr[38][k], arr[6][k], arr2[7][k], arr[32][k],
 | 
			
		||||
      arr2[10][k], arr2[13][k], arr[20][k], arr[33][k], arr[23][k], arr[9][k],
 | 
			
		||||
      arr[25][k], arr2[8][k], arr[39][k], arr2[17][k], arr[21][k], arr[16][k],
 | 
			
		||||
      arr[5][k], arr[34][k], arr2[18][k], arr2[9][k], arr[14][k], arr[10][k],
 | 
			
		||||
      arr[0][k], arr2[12][k], arr[31][k], arr2[11][k], arr2[16][k], arr[27][k],
 | 
			
		||||
      arr[24][k], arr[13][k], arr[29][k], arr2[3][k], arr2[21][k], arr2[20][k],
 | 
			
		||||
      arr[18][k], arr[19][k], arr[22][k], arr[26][k], arr[36][k], arr[17][k],
 | 
			
		||||
      arr2[15][k], arr[2][k], arr2[14][k], arr[35][k]);
 | 
			
		||||
 | 
			
		||||
      write(ret0);
 | 
			
		||||
      write(ret1);
 | 
			
		||||
end.
 | 
			
		||||
		Reference in New Issue
	
	Block a user