Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Question!


Name: Alina
Title:
  translate it to python
Question:
gram project12;
var
  a,b:array[1 .. 1000] of integer;
  i,n,l,r,m,k,c:integer;
begin
  readln(n,k);
  for i:=1 to n do
    readln(a[i]);
  for i:=1 to k do
    readln(b[i]);
  for i:=1 to k do
    begin
      l:=1;
      r:=n;
      while l<>r do
        begin
          m:=(l r) div 2;
          if (b[i]<=a[m]) then
            r:=m
          else
            l:=m 1;
        end;
  if(a[r-1]-b[i]<0) then
    c:=(a[r-1]-b[i])*(-1)
  else
    c:=a[r-1]-b[i];
  if (r<>1) and ((a[r]-b[i]<c) or(a[r]-b[i]=0)and(c<>0))or(r=1)then
    writeln(a[r])
  else
    writeln(a[r-1]);
  end;
  readln
end.
Answers:

Name: songyuhui
jshxajjdhbxba

Name: banme
ne mogu f[[f[f[f[f[f[