ural1030有一点恶心, 写了半天才把公式推出来
/*以地心为原点建立空间直角坐标系*/
const s=纬度; t=经度; r=6875/2;
x=r*cos(s)*sin(t);
if t in west then x:=x*(-1);
y=r*cos(s)*cos(t);
z=r*sin(s);
if s in south then z:=z*(-1);
d:=sqrt(sqr(x1-x2)+sqr(y1-y2)+sqr(z1-z2));
ans:=arcsin((d/2)/r)*2*r;
//代码有点乱
const r=6875/2;
var i,j,k,m,n,l:longint;
direction:array[1..2,1..3]of extended;
ss,t:string;
function get(var s:string):longint;
var k:longint;
begin
k:=0;
while (s[1]<'0')or(s[1]>'9') do delete(s,1,1);
while (s[1]>='0')and(s[1]<='9') do
begin
[ 阅读全文]
写几何染色写了这么久,才知道什么是离散化 -_-|||
感觉比较恶心,因为写快排都爆栈,只好删除快排的局部变量
const maxn=5000;
black=0; white=1;
maxh=48889;
var i,j,k,m,n,l,t:longint;
c:char;
a:array[0..maxn]of record l,r,c:longint; end;
d:array[0..maxn*2+1]of longint;
g,f,temp:array[0..maxh]of longint;
line:array[1..maxn*2+1]of longint;
ans_a,ans_b,max,now_a,tot:longint;
procedure sort(x,y:longint);
var i:longint;
begin
t:=random(y-x+1)+x;
[ 阅读全文]
//Strongly Connected Component
const maxn=1000;
type node=^nd;
nd=record nam,val:longint; next:node; end;
var i,j,k,m,n,l:longint;
a:array[1..maxn]of node;
belong,ins,s,dfn,low:array[1..maxn]of longint;
v:array[1..maxn]of boolean;
head,now,temp:longint;
procedure dfs(i:longint);
var p:node;
begin
inc(now); dfn[i]:=now; low[i]:=now;
inc(head); s[head]:=i; v[i]:=true; p:=a[i];
while [ 阅读全文]
const maxn=1001;
type node=^nd;
nd=record nam,c:longint; same,next:node; end;
var i,j,k,m,n,l,s,t:longint;
a,b,sp:array[0..maxn]of node;
q,lv,stack:array[0..maxn]of longint;
head,tail,max_flow,flow:longint;
p:node;
function bfs:boolean;
begin
fillchar(lv,sizeof(lv),$ff);
head:=0; tail:=1; q[1]:=s; lv[s]:=0;
while head<tail do
[ 阅读全文]