题解:
乘积最小只需要取对数。然后反向边就变成1/c,而不是-c了。
精度问题搞得我已经我想说什么了。。。
贴一份网上的pascal
代码;
1 type ss=record 2 x,y,c,r,next:longint; 3 f:extended; 4 end; 5 const maxn=401; maxm=46001; qu=10000; oo=maxlongint shr 2; 6 var i,j,n,cnt,st,ed,w,tot,t1,t2,t4,k,t,h,flow,augo,hh,tt:longint; 7 pr:string; 8 s,x:array[0..maxn] of extended; 9 y,pre,b:array[0..maxn] of longint; 10 f:array[0..maxn] of boolean; 11 e:array[0..maxm] of ss; 12 q:array[0..qu] of longint; 13 ans,t3,cost:extended; 14 procedure jia(x,y,c:longint;f:extended); 15 begin 16 inc(tot); e[tot].x:=x; e[tot].y:=y; e[tot].c:=c; e[tot].f:=f; 17 e[tot].next:=b[x]; b[x]:=tot; 18 inc(tot); e[tot].x:=y; e[tot].y:=x; e[tot].f:=-f; 19 e[tot].next:=b[y]; b[y]:=tot; 20 e[tot].r:=tot-1; e[tot-1].r:=tot; 21 end; 22 begin 23 readln(n,k); 24 for i:=1 to n do read(x[i]); 25 for i:=1 to n do read(y[i]); 26 st:=n+1; ed:=n+2; cnt:=n+3; fillchar(b,sizeof(b),255); 27 jia(st,cnt,k,0); 28 for i:=1 to n do 29 if y[i]>0 then jia(cnt,i,y[i],-ln(x[i])); 30 for i:=1 to n do 31 begin 32 read(t); 33 if t=1 then jia(i,ed,oo,0); 34 end; 35 while true do 36 begin 37 read(t1,t2); 38 if t1=-1 then break; 39 readln(t3,t4); 40 jia(t1,t2,t4,-ln(t3)); 41 jia(t2,t1,t4,-ln(t3)); 42 end; 43 ans:=1; 44 while true do 45 begin 46 for i:=1 to cnt do s[i]:=oo; 47 h:=1; t:=1; q[1]:=st; s[st]:=0; hh:=1; tt:=1; 48 repeat 49 w:=q[h]; f[w]:=false; i:=b[w]; 50 inc(h); inc(hh); h:=h mod qu; 51 while i<>-1 do 52 begin 53 if (s[e[i].y]-s[w]-e[i].f>1e-12) and (e[i].c>0) then 54 begin 55 s[e[i].y]:=s[w]+e[i].f; 56 pre[e[i].y]:=i; 57 if not(f[e[i].y]) then 58 if s[e[i].y]<s[q[h]] then 59 begin 60 dec(h); dec(hh); 61 if h<0 then h:=qu-1; 62 q[h]:=e[i].y; 63 end 64 else 65 begin 66 inc(t); inc(tt); 67 t:=t mod qu; 68 q[t]:=e[i].y; 69 end; 70 f[e[i].y]:=true; 71 end; 72 i:=e[i].next; 73 end; 74 until hh>tt; 75 if s[ed]=oo then break; 76 flow:=maxlongint; 77 i:=pre[ed]; 78 while i<>0 do 79 begin 80 if flow>e[i].c then flow:=e[i].c; 81 i:=pre[e[i].x]; 82 end; 83 i:=pre[ed]; cost:=0; 84 while i<>0 do 85 begin 86 cost:=e[i].f+cost; dec(e[i].c,flow); 87 inc(e[e[i].r].c,flow); i:=pre[e[i].x]; 88 end; 89 for i:=1 to flow do ans:=ans*exp(-cost); 90 inc(augo,flow); 91 end; 92 if augo<k then writeln(0) else 93 begin 94 write('0.'); ans:=ans*10; 95 while ans<1 do 96 begin 97 ans:=ans*10; 98 write(0); 99 end; 100 for i:=1 to 10 do ans:=ans*10; 101 for i:=1 to 6 do ans:=round(ans/10); 102 writeln(trunc(ans)); 103 end; 104 end.