text:
# A (p,q)-Steiner system on a set A is a family of subsets of A (called blocks),
# each of size q, such that each subset of size p in A is contained ina unique
# block.

steiner_number_test := proc(p::posint,q::posint,n::posint)
 local i,m;
 for i from 0 to p-1 do
  m := binomial(n-i,p-i)/binomial(q-i,p-i);
  if not(type(m,integer)) then
   return false;
  fi;
 od:
 return true;
end:

`is_element/steiner_systems` := (A::set) -> (p::posint,q::posint) -> proc(S)
 global reason;

 local P,B,CC;

 if not(type(S,set(set))) then
  reason := ["is_element/steiner_systems","S is not a set of sets",S];
  return false;
 fi;

 if map(op,S) minus A <> {} then
  reason := ["is_element/steiner_systems","S is not a set of subsets of A",S,A];
  return false;
 fi;

 if map(nops,S) <> {q} then
  reason := ["is_element/steiner_systems","S is not a set of sets of size q",S,q];
  return false;
 fi;

 P := combinat[choose](A,p);

 for B in P do
  CC := select(C -> B minus C = {},S);
  if nops(CC) <> 1 then
   reason := ["is_element/steiner_systems","The set B is not contained in a unique block",B,CC];
   return false;
  fi;
 od:

 return true;
end:

`res/steiner_system` := (A::set,B::set) -> proc(S)
 local T;

 if B minus A <> {} then
  error("B is not a subset of A");
 fi;

 if nops(S[1]) + nops(B) < nops(A) then
  error("B is too small");
 fi;

 T := select(C -> C union B = A,S);
 T := map(C -> C intersect B,T);

 return T;
end:

# A (1,q)-Steiner system on A is just a partition of A into disjoint blocks of
# size q.  There is an obvious way to make such a partition when A = {1,..,m*q}

`steiner_system/congruence` := proc(q,m)
 local i,j;
 [{seq(i,i=1..q*m)},
  {seq({seq(j,j=i*q+1..(i+1)*q)},i=0..m-1)},
  [1,q,m*q]];
end:

# For any prime p, the lines in (Z/p)^2 give a (2,p)-Steiner system.

`steiner_system/affine` := proc(p)
 local V,S,i,j,m,c;

 if not(isprime(p)) then
  return FAIL;
 fi;

 V := {seq(seq([i,j],j=0..p-1),i=0..p-1)};
 S := {seq({seq([i,j],j=0..p-1)},i=0..p-1),
       seq(seq({seq([i,modp(m*i+c,p)],i=0..p-1)},c=0..p-1),m=0..p-1)};
 return [V,S,[2,p,p^2]];
end:

ext: mpl

lm_label:
1. YES
2. YES


text:
with(simplex);

Constraints := [
# conservation of units at each node
e13+e14 = 300, # CHI
e23+e24 = 300, # DC
e13+e23 = 300, # HOU
e14+e24 = 300, # BOS
# maximum flow on individual edges
0 <= e13, e13 <= 200,
0 <= e14, e14 <= 200,
0 <= e23, e23 <= 280,
0 <= e24, e24 <= 350
];

Cost := 7*e13 + 6*e14 + 4*e23 + 6*e24;
# Invoke linear programming to solve problem
minimize (Cost, Constraints, NONNEGATIVE);


text:
est_pi := proc(num_steps::integer)
   local step, s, x, mypi, i, start_time, stop_time:
   printf("  Estimating Pi using: %1d slices\n", num_steps):
   start_time := time[real]():
   step := 1.0/num_steps:
   s:=0:
   for i from 1 to num_steps do
      x:=(i-0.5)*step:
      s:=s+(4.0/(1.0 + x*x)):
   end do:
   mypi:=s*step:
   stop_time := time[real]():
   printf("Estimated value of Pi: %.16g\n", mypi):
   printf("      Elapsed time(s): %.16g\n", stop_time - start_time):
   printf("  Observed difference: %.16g\n", abs(Pi - mypi)):
   mypi;
end proc:

native_est_pi := proc(num_steps::integer)
   local step, mypi, k, start_time, stop_time:
   printf("  Estimating Pi using: %1d slices\n", num_steps):
   start_time := time[real]():
   mypi:=Re(sum((4/(1+(((k-0.5)/num_steps)^2))),k=1..num_steps)/num_steps):
   stop_time := time[real]():
   printf("Estimated value of Pi: %.16g\n", mypi):
   printf("      Elapsed time(s): %.16g\n", stop_time - start_time):
   printf("  Observed difference: %.16g\n", abs(Pi - mypi)):
   mypi;
end proc:


text:
program sample19;
	/* Calculator program	*/
	/*  c n : clear & set n	*/
	/*  + n : add n			*/
	/*  - n : subtract n	*/
	/*  * n : multiply n	*/
	/*  / n : divide by n		*/
	/*  o : off				*/
procedure gcmlcm(m, n, gc, lc : integer);
	/* gc := GCM(m,n), lc := LCM(m,n) */
	/* m and n are not changed        */
 var a,b,r : integer;
begin
	a := m;
	b := n;
	while b <> 0 do begin
		r := a - (a div b) * b;
		a := b;
		b := r
	end;
	gc := a;
	lc := (m div gc) * n
end;
procedure abs(a, b : integer);
begin
  if a < 0 then b := -a  else b := a
end;
procedure gcm(a, b, gc : integer);
 var lc, aa, bb : integer;
begin
  if (a = 0) or (b = 0) then gc := 1
  else begin
  call abs(a,aa);  call abs(b,bb);
  call gcmlcm(aa, bb, gc, lc)
  end
end;
procedure lcm(a, b, lc : integer);
 var gc, aa, bb : integer;
begin
  if (a = 0) or (b = 0) then lc := 1
  else begin
  call abs(a,aa);  call abs(b,bb);
  call gcmlcm(aa, bb, gc, lc)
  end
end;
procedure reduce(a1, a2 : integer);
  var gc : integer;
begin
  if a1 = 0 then begin a2 := 1; return end;
  if a2 = 0 then begin a1 := 1; return end;
  if a2 < 0 then begin a2 := -a2; a1 := -a1 end;
  call gcm(a1, a2, gc);
  a1 := a1 div gc;
  a2 := a2 div gc
end;

procedure sum(x1, x2, y1, y2 : integer);
 var lc, y11 : integer;
begin
  call lcm(x2, y2, lc);
  x1 := x1 * (lc div x2);
  y11 := y1 * (lc div y2);
  x1 := x1 + y11;
  x2 := lc;
  call reduce(x1, x2)
end;
procedure sub(x1, x2, y1, y2 : integer);
 var lc, y11 : integer;
begin
  call sum(x1, x2, -y1, y2)
end;
procedure mult(x1, x2, y1, y2 : integer);
 var gc, y11, y22 : integer;
begin
  call gcm(x1, y2, gc);
  x1 := x1 div gc;
  y22 := y2 div gc;
  call gcm(x2, y1, gc);
  x2 := x2 div gc;
  y11 := y1 div gc;
  x1 := x1 * y11;
  x2 := x2 * y22;
  call reduce(x1, x2)
end;
procedure divide(x1, x2, y1, y2 : integer);
begin
	call mult(x1, x2, y2, y1)
end;

procedure printfinal(a, b : integer);
begin
  if a = 0 then writeln('Final'' Result =', a)
  else if b = 1 then writeln('Final Result =', a)
  else writeln('Final Result =', a, '/', b)
end;
procedure printtemp(a, b : integer);
begin
  if a = 0 then writeln('Temporary Result =', a)
  else if b = 1 then writeln('Temporary Result =', a)
  else writeln('Temporary Result =', a, '/', b)
end;

var	x1, x2, y1,y2 : integer;
var	com :char;
	endflag : boolean;
begin
	writeln('   *** Calculator -- h for help ***');
	x1 := 0;  x2 :=1;
	endflag := false;
	while not endflag do begin
		writeln(' Please input command :');
		readln(com, y1);  y2 := 1;
		if (com = 'c')  or (com = 'C') then begin x1 := y1; x2 := y2 end
		else if com = '+' then call sum(x1, x2, y1, y2)
		else if com = '-' then call sub(x1, x2, y1, y2)
		else if com = '*' then call mult(x1, x2, y1, y2)
		else if com = '/' then call divide(x1, x2, y1, y2)
		else if (com = 'o') or (com = 'O') then endflag := true
		else begin
			writeln;
			writeln('Calculator Usage:');
			writeln('  c number : clear & set it');
			writeln('  + number : add it');
			writeln('  - number : subtract it');
			writeln('  * number : multiply it');
			writeln('  / number : divide by it');
			writeln('  o        : off(terminate execution)');
			writeln
		end;
		if endflag then call printfinal(x1, x2)
		else call printtemp(x1, x2)
	end
end.

lm_label:
1. Yes
2. Yes