174. 174. 1000 , K. , .
: . , . , . , , . , . , . , , , , . .
program poisk_2;
const n = 1000;
var k, p, a, b: integer;
mas: array[1..n] of integer;
begin
for a:= 1 to n do mas[a]:= a;
write('K = '); readln(k);
a:= 1; b:= n;
while a <> b do
begin
p:= (a + b) div 2;
if mas[p] < k then a:= p + 1
else b:=p
end;
write(' = ',a);
readln
end.
175. 175. (ղ . , 10.04.1998 .)
. . , . , () : , . (, ). . ( ), , , . , , , . , , . . , , , .
: , , , : . , , .
, , . , , . .
|
|
. LIFO Last In First Out, 쳺 . . , () (), . -, ( ) . ( ) , , . -. .
, . , , . , . , , . nsk period. . ³ , - . , . . , :
program clock;
uses crt;
var s,m,h: byte;
sec, min, time: array[0..60] of integer;
lotok: array[0..1060] of integer;
kul,i: integer;
function nsk(a,b:longint):longint;
var a1,b1: longint;
begin
a1:=a; b1:=b;
while a<>b do if a>b then a:=a-b else b:=b-a;
nsk:= (a1 div a)*b1;
end;
procedure period;
var j: integer;
t,l: longint;
begin
t:=1; write(': ');
for i:=1 to kul do
begin
j:=i;l:=0;
repeat
j:=lotok[j];inc(l);
until j=i;
t:=nsk(t,l);write(l,' ');
end; writeln;
writeln(' = ',t);
writeln(' ',t,' ');
end;
begin
writeln;
write(' : ');readln(s);
write(' : ');readln(m);
write(' : ');readln(h);
write(' : ');readln(kul);
{ }
for i:=1 to kul do lotok[i]:=i; { }
lotok[0]:=kul+1; { }
min[0]:=1; { }
time[0]:=1; { }
while time[0]<=h do
begin
for i:=1 to s do sec[i]:=lotok[i]; { }
for i:=1 to kul-s do lotok[i]:=lotok[i+s]; { }
lotok[0]:=lotok[0]-s; { }
min[min[0]]:= sec[s]; { }
|
|
{ }
for i:=1 to s-1 do lotok[lotok[0]+i-1]:=sec[s-i];
lotok[0]:=lotok[0]+s-1;{ }
inc(min[0]); { 1 }
if min[0]=m+1 then { }
begin
time[time[0]]:=min[m]; { }
{ }
for i:=1 to m-1 do lotok[lotok[0]+i-1]:=min[m-i];
lotok[0]:=lotok[0]+m-1; { }
min[0]:=1; { }
inc(time[0]); { }
end;
if time[0]=h+1 then { }
begin
{ }
for i:=1 to h do lotok[lotok[0]+i-1]:=time[h-i+1];
end;
end; { () }
period;
readln
end.
176. 176. , 20 .
177. 177. 12 . , ?
178. 178. 10 18 ᒺ . , , ᒺ , ( ). .
179. 179. 15 . , , .
180. 180. X, Y, Z :
) Y ;
) Y : Y[1]:= X[1] + X[N]; Y[2]:= X[2] + X[N1],..., Y[N]:= X[N] + X[1].
) Y , [A, B].
) Y 10 , Z 15 .
) Y , Z , 3.
) Y , Գ, Z , .
181. 181. 15 . ϳ (10 15). , ? ?
182. 182. 5 . . , , , . ʳ 20.
183. 183. , , . (10 20). . .
184. 184. , , .
185. 185. , .
186. 186. . , .
187. 187. 1000 , K.
|
|