NOIP2016第四题

题目:https://www.luogu.org/problem/show?pid=2119

刘可盈同学的分析及代码:

var
  n,m,i,xa,xb,xc,xd:longint;
  x,a,b,c,d:array[0..40000] of longint;
begin
  assign(input,'magic.in');
  reset(input);
  assign(output,'magic.out');
  rewrite(output);
  readln(n,m);
  for i:=1 to m do readln(x[i]);
  for xa:=1 to m do                              
    for xb:=1 to m do if (xa<>xb) and (x[xa]<x[xb]) then
      for xc:=1 to m do if (x[xb]<x[xc]) and (xc<>xa) and (xc<>xb) and (x[xb]-x[xa]<(x[xc]-x[xb])/3) then
        for xd:=1 to m do if (x[xc]<x[xd]) and (xd<>xa) and (xd<>xb) and (xd<>xc) and (x[xb]-x[xa]=2*(x[xd]-x[xc])) then begin
           a[xa]:=a[xa]+1;b[xb]:=b[xb]+1;c[xc]:=c[xc]+1;d[xd]:=d[xd]+1;
        end;
  for i:=1 to m do writeln(a[i],' ',b[i],' ',c[i],' ',d[i]);
  close(input);
  close(output);
end.

 

posted @ 2017-01-12 15:17  lsnoip  阅读(132)  评论(0)    收藏  举报