C11TRCNT - Bắn máy bay

Tác giả: ladpro98

Ngôn ngữ: Pascal

program c11trcnt;
uses    math;
type    point=record
        x,y:longint;
        s:longint;
        end;

        vector=record
        x,y:int64;
        end;
const   maxN=222;
        fi='';
var     a:array[1..maxN] of point;
        n,res:longint;

procedure input;
var     inp:text;
        i:longint;
begin
        assign(inp,fi);
        reset(inp);
        readln(inp,n);
        for i:=1 to n do
        readln(inp,a[i].x,a[i].y);
        close(inp);
end;

procedure process;
var     i,j,k:longint;
        v1,v2:vector;
begin
        for i:=1 to n do
        for j:=i+1 to n do
        for k:=j+1 to n do
        begin
                v1.x:=a[j].x-a[i].x;
                v1.y:=a[j].y-a[i].y;
                v2.x:=a[k].x-a[i].x;
                v2.y:=a[k].y-a[i].y;
                if not ((v1.x*v2.y)=(v1.y*v2.x)) then
                begin
                        inc(res);
                        inc(a[i].s);
                        inc(a[j].s);
                        inc(a[k].s);
                end;
        end;
end;

procedure output;
var     t,i:longint;
begin
        write(res,' ');
        t:=1;
        for i:=2 to n do
        if a[i].s<a[t].s then
        t:=i;
        write(t);

end;

begin
        input;
        process;
        output;
end.

Download