Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一遍AC,贴代码(Pascal):

Posted by skywalker_z at 2011-08-03 10:24:32 on Problem 1046
var n,i,tr,tg,tb,cur,curi:longint;
  r,g,b:array[1..16]of longint;
procedure rec;
  var sr,sg,sb:longint;
  begin
    sr:=sqr(tr-r[i]);
    sg:=sqr(tg-g[i]);
    sb:=sqr(tb-b[i]);
    if sr+sg+sb<cur then begin
      cur:=sr+sg+sb; curi:=i;
    end;
  end;
begin
  for i:=1 to 16 do readln(r[i],g[i],b[i]);
  while true do begin
    readln(tr,tg,tb);
    if tr<0 then break;
    cur:=maxlongint;
    for i:=1 to 16 do rec;
    writeln('(',tr,',',tg,',',tb,') maps to (',r[curi],',',g[curi],',',b[curi],')');
  end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator