/ SB域 /

记录详情

Accepted

/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
# 状态 耗时 内存占用
#1 Accepted 1ms 256.0 KiB
#2 Accepted 0ms 256.0 KiB
#3 Accepted 1ms 256.0 KiB
#4 Accepted 1ms 256.0 KiB
#5 Accepted 0ms 256.0 KiB
#6 Accepted 1ms 256.0 KiB
#7 Accepted 1ms 256.0 KiB
#8 Accepted 1ms 256.0 KiB
#9 Accepted 1ms 256.0 KiB
#10 Accepted 1ms 256.0 KiB
#11 Accepted 1ms 256.0 KiB
#12 Accepted 1ms 256.0 KiB
#13 Accepted 1ms 256.0 KiB
#14 Accepted 1ms 256.0 KiB

代码

var i,root,n:longint;
    sum:int64;
    fa:array[0..1000]of boolean;
    p,q,r,b:array[1..1000]of longint;
function gcd(a,b:longint):longint;
 begin
  if b=0 then gcd:=a
   else gcd:=gcd(b,a mod b);
end;
procedure build(k:longint; var ans:int64);
var t,d1,d2:int64;
begin
 if r[k]<>0 then build(r[k],d1) else d1:=1;
 if b[k]<>0 then build(b[k],d2) else d2:=1;
 t:=(p[k]*d1)*(q[k]*d2) div gcd(p[k]*d1,q[k]*d2);
 ans:=t div p[k]+ t div q[k];
end;
begin
 readln(n);
 for i:=1 to n do begin
  readln(p[i],q[i],r[i],b[i]);
  fa[r[i]]:=true;
  fa[b[i]]:=true;
 end;
 for i:=1 to n do
  if fa[i]=false then root:=i;
 build(root,sum);
 writeln(sum);
 close(input);close(output);
end.

信息

递交者
类型
递交
题目
最轻的天平
题目数据
下载
语言
Pascal
递交时间
2017-08-22 16:45:56
评测时间
2017-08-22 16:55:40
评测机
分数
100
总耗时
18ms
峰值内存
256.0 KiB