Var input,output:text; n,i,j,g,nm,ans,t:integer;ara:array[0..1000] of integer;ar,arq:array[0..1000] of integer; ts,sum,a:integer;beginassign(input,'f.in');reset(input); assign(output,'f.out');rewrite(output);readln(input,a,n);ans:=10000; for i:=1 to n do beginread(input,ar[i]);ts:=ts+2*ar[i];end; if ts<a then writeln(output,'-1') else begin
ara[1]:=3;for i:=2 to 15 do begin ara[i]:=3*ara[i-1];end; for i:=1 to ara[n] do begin if arq[n]<2 then begin inc(arq[n]);sum:=sum+ar[n];inc(nm); end else begin g:=n;while arq[g]>1 do begin sum:=sum-ar[g]*arq[g];dec(nm,arq[g]);arq[g]:=0;dec(g);end; inc(arq[g]);sum:=sum+ar[g];inc(nm);end;if sum=a then begin if nm<ans then ans:=nm;end;end; if ans>1000 then writeln(output,'0') else writeln(output,ans); end; close(output);close(input);end.
2 Кбайт/сек
Объяснение:
V = I / t, где
V - скорость передачи информации
I - количество информации в сообщении
t - время передачи сообщения
I = К * i, где
I - количество информации в сообщении
К - количество символов в тексте
i - количество информации, которое несет каждый символ алфавита
N = 2^i, где
N - мощность алфавита
i - количество информации, которое несет каждый символ алфавита
Дано:
t = 2 мин 8 сек = 128 сек = 2⁷ сек
N = 256 = 2⁸
К = 128 страниц * 32 строки * 64 символа = 2⁷ * 2⁵ * 2⁶ = 2¹⁸ символов
Найти:
V
2⁸ = 2^i
i = 8 бит = 1 байт
I = 2¹⁸ * 1 = 2¹⁸ байт
V = 2¹⁸ / 2⁷ = 2¹¹ байт/сек = 2 Кбайт/сек
1 мин = 60 сек
1 байт = 8 бит
1 Кбайт = 1024 байт = 2¹⁰ байт
for i:=1 to n do beginread(input,ar[i]);ts:=ts+2*ar[i];end;
if ts<a then writeln(output,'-1') else
begin
ara[1]:=3;for i:=2 to 15 do begin ara[i]:=3*ara[i-1];end;
for i:=1 to ara[n] do begin if arq[n]<2 then begin inc(arq[n]);sum:=sum+ar[n];inc(nm); end else begin g:=n;while arq[g]>1 do begin sum:=sum-ar[g]*arq[g];dec(nm,arq[g]);arq[g]:=0;dec(g);end;
inc(arq[g]);sum:=sum+ar[g];inc(nm);end;if sum=a then begin if nm<ans then ans:=nm;end;end;
if ans>1000 then writeln(output,'0') else writeln(output,ans); end;
close(output);close(input);end.