BZOJ1180

水题.对于最后的方案,表达式必然是下面这个样子的:

(Xa1-Xb1)+(Ya1-Yb1)+(Xa2-Xb2)+(Ya2-Yb2)+...+(Xan-Xbn)+(Yan-Ybn)

去掉括号,就等于|∑Xai-∑Xbi|+|∑Yai-∑Ybi| (1<=i<=n)

读入完就出解了.

code:

/************************************************************** Problem: 1108User: exponent Language: Pascal Result: Accepted Time:908 ms Memory:224 kb 
****************************************************************/ var   n,i,x,y:longint; sumx,sumy:int64; beginreadln(n); for i:=1 to n dobeginreadln(x,y); inc(sumx,x); inc(sumy,y); end; for i:=1 to n dobeginreadln(x,y); dec(sumx,x); dec(sumy,y); end; writeln(abs(sumx)+abs(sumy)); 
end.

转载于:.html

BZOJ1180

水题.对于最后的方案,表达式必然是下面这个样子的:

(Xa1-Xb1)+(Ya1-Yb1)+(Xa2-Xb2)+(Ya2-Yb2)+...+(Xan-Xbn)+(Yan-Ybn)

去掉括号,就等于|∑Xai-∑Xbi|+|∑Yai-∑Ybi| (1<=i<=n)

读入完就出解了.

code:

/************************************************************** Problem: 1108User: exponent Language: Pascal Result: Accepted Time:908 ms Memory:224 kb 
****************************************************************/ var   n,i,x,y:longint; sumx,sumy:int64; beginreadln(n); for i:=1 to n dobeginreadln(x,y); inc(sumx,x); inc(sumy,y); end; for i:=1 to n dobeginreadln(x,y); dec(sumx,x); dec(sumy,y); end; writeln(abs(sumx)+abs(sumy)); 
end.

转载于:.html