Informatika va axborot tеxnologiyalari ta’lim yo‘nalishi talabalari uchun “Informatika” fanidan test savollari (1-tur)



Yüklə 23,67 Kb.
səhifə9/9
tarix13.05.2022
ölçüsü23,67 Kb.
#57815
1   2   3   4   5   6   7   8   9
Олимпиада информатика TESTI

Mumkin bo'lgan masala echimlari
program P_2;

var i,j,k,t,l:integer;

a:array[1..3,1..3] of integer;

begin


for i:=1 to 3 do

for j:=1 to 3 do

begin write('a(',i,',',j,')='); readln(a[i,j]); end;

for i:=1 to 3 do

begin

k:=a[i,1]; t:=1;



for j:=1 to 3 do if k

l:=a[i,i]; a[i,i]:=a[i,t]; a[i,t]:=l;

end;

for i:=1 to 3 do



begin

for j:=1 to 3 do write(a[i,j],' ');

writeln;

end;


readln;

end.
program P_4;

const MAX_BUFFER_SIZE = 10000;

var a,b,n:integer;

buffer:array[0..MAX_BUFFER_SIZE] of integer;

buffer_size:integer;


procedure check(pa,pb:integer);

var i:integer;

begin

for i:=0 to buffer_size do



if (buffer[i]=pa) or (buffer[i]=pb) then

begin


writeln(pa:5,pb:6);

writeln(-1);

halt;

end;


if (buffer_size < MAX_BUFFER_SIZE) then

begin


inc(buffer_size);

buffer[buffer_size]:=pa;

end;

end;
begin



read(a,b);

buffer_size:=0;

buffer[0]:=a;

n:=0;


while (a<>0) and (b<>0) do

begin


if (a>b) then

begin a:=a-b; b:=b+b; end

else

begin b:=b-a; a:=a+a; end;



inc(n);

check(a,b);

writeln(a:5,b:6);

end;


writeln(n);

end.
program P_3;

const MAX_COUNT = 1000;

var n,i,s,best_length:longint;

a:array[1..MAX_COUNT] of integer;

curr,best:array[1..MAX_COUNT,1..2] of integer;

used:array[1..MAX_COUNT] of boolean;
procedure save(p:integer);

var i:integer;

begin

best_length := p;



for i:=1 to best_length do

best[i] := curr[i];

end;
procedure put(p,s:integer);

var i,j:integer;

begin

if (p>best_length) then exit;



if (s=0) then

begin


save(p-1);

exit;


end;

for i:=n downto 1 do

if (not used[i]) then

begin


used[i] := true;

curr[p][1] := i;

for j:=(s div a[i]) downto 1 do

begin


curr[p][2] := j;

put( p+1, s - j * a[i] );

end;

used[i] := false;



end;

end;
begin

read(n);

for i:=1 to n do

begin

read(a[i]);



used[i] := false;

end;


read(s);
best_length := n+1;

put(1,s);


if (best_length < n+1) then

begin


writeln(best_length);

for i:=1 to best_length do

begin

if (i>1) then write(' + ');



write(best[i][2],'*',a[best[i][1]]);

end;


writeln;

end


else

writeln(-1);



end.

Kompyuter grafikasidan tast savollarining javoblari



S

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

J

D

C

A

B

A

D

B

D

A

B

B

C

D

D

D

B

A

A

C

B

Yüklə 23,67 Kb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin