题意:

思路:单纯形模板

 var a:array[..,..]of double;
idx,idy,q:array[..]of longint;
c:array[..]of double;
n,m,i,j,op,x,y:longint;
eps,mn:double; procedure swap(var x,y:longint);
var t:longint;
begin
t:=x; x:=y; y:=t;
end; procedure pivot(x,y:longint);
var i,j,tot:longint;
tmp:double;
begin
swap(idy[x],idx[y]);
tmp:=a[x,y]; a[x,y]:=/a[x,y];
for i:= to n do
if y<>i then a[x,i]:=a[x,i]/tmp;
tot:=;
for i:= to n do
if (i<>y)and((a[x,i]>eps)or(a[x,i]<-eps)) then
begin
inc(tot); q[tot]:=i;
end;
for i:= to m do
begin
if (x=i)or((a[i,y]<eps)and(a[i,y]>-eps)) then continue;
for j:= to tot do a[i,q[j]]:=a[i,q[j]]-a[x,q[j]]*a[i,y];
a[i,y]:=-a[i,y]/tmp;
end;
end; begin
//assign(input,'uoj179.in'); reset(input);
//assign(output,'uoj179.out'); rewrite(output);
readln(n,m,op);
randomize;
eps:=1e-8;
for i:= to n do read(a[,i]);
for i:= to m do
begin
for j:= to n do read(a[i,j]);
read(a[i,]);
end;
for i:= to n do idx[i]:=i;
for i:= to m do idy[i]:=i+n;
while true do
begin
x:=; y:=;
for i:= to m do
if (a[i,]<-eps)and((x=)or(random()=)) then x:=i;
if x= then break;
for i:= to n do
if (a[x,i]<-eps)and((y=)or(random()=)) then y:=i;
if y= then
begin
writeln('Infeasible');
// close(input);
//close(output);
exit;
end;
pivot(x,y);
end;
while true do
begin
x:=; y:=; mn:=1e15;
for i:= to n do
if a[,i]>eps then begin y:=i; break; end;
if y= then break;
for i:= to m do
if (a[i,y]>eps)and(a[i,]/a[i,y]<mn) then
begin
mn:=a[i,]/a[i,y]; x:=i;
end;
if x= then
begin
writeln('Unbounded');
// close(input);
// close(output);
exit;
end;
pivot(x,y);
end;
writeln(-a[,]::);
if op= then exit;
for i:= to m do
if idy[i]<=n then c[idy[i]]:=a[i,];
for i:= to n do
begin
write(c[i]::);
if i<n then write(' ');
end; //close(input);
//close(output);
end.

【UOJ179】线性规划(单纯形)的更多相关文章

  1. 【UOJ #179】线性规划 单纯形模板

    http://uoj.ac/problem/179 终于写出来了单纯性算法的板子,抄的网上大爷的qwq 辅助线性规划找非基变量时要加个随机化才能A,我也不知道为什么,卡精度吗? 2017-3-6UPD ...

  2. UVA 10498 Happiness(线性规划-单纯形)

    Description Prof. Kaykobad has given Nasa the duty of buying some food for the ACM contestents. Nasa ...

  3. UOJ179 线性规划

    Description 这是一道模板题. 本题中你需要求解一个标准型线性规划: 有\(n\)个实数变量\(x_1,x_2,\cdots,x_n\)和\(m\)条约束,其中第\(i\)条约束形如\(\s ...

  4. 【UOJ#179】线性规划 单纯形

    题目链接: http://uoj.ac/problem/179 Solution 就是单纯形模板题,这篇博客就是存一下板子. Code #include<iostream> #includ ...

  5. UOJ.179.线性规划(单纯形)

    题目链接 这写得还不错:http://www.cnblogs.com/zzqsblog/p/5457091.html 引入基变量\(x_{i+n}\),将约束\(\sum_{i=1}^m a_{ij} ...

  6. 线性规划VB求解

    线性规划VB求解 Rem 定义动态数组 Dim a() As Single, c() As Single, b() As Single, cb() As Single Dim aa() As Sing ...

  7. 机器学习-线性规划(LP)

    线性规划问题 首先引入如下的问题: 假设食物的各种营养成分.价格如下表: Food Energy(能量) Protein(蛋白质) Calcium(钙) Price Oatmeal(燕麦) 110 4 ...

  8. BZOJ 1061: [Noi2008]志愿者招募

    1061: [Noi2008]志愿者招募 Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 4064  Solved: 2476[Submit][Stat ...

  9. 【置顶】Trotyl's OI tree

    \(\rm thx\):@\(\rm UntilMadow\) ! \(\color{Green}{\rm Pupil}\) :只会一点点 \(\color{blue}{\text{Expert}}\ ...

  10. PKUSC 2022 口胡题解

    \(PKUSC\ 2022\)口胡题解 为了更好的在考试中拿分,我准备学习基础日麻知识(为什么每年都考麻将 啊啊啊) 首先\(STO\)吉老师\(ORZ,\)真的学到了好多 观察标签发现,这套题覆盖知 ...

随机推荐

  1. 15分钟学会使用Git

    http://blog.csdn.net/u013510614/article/details/50588446 主体思想 Git作为一个复杂的版本控制系统,命令之多,相信很多小白已经望而却步,有的尝 ...

  2. 众皓网络(T 面试)

    1.你们项目中哪里用到了Redis? 2.Redis中存储的数据,你们什么时候进行更新? 3.你用过消息队列吗? 4.你写的这个微服务项目拆分成了几个服务? 5.SpringCloud项目怎么部署的?

  3. eclipse生成spring boot jar包

    1.右击项目,选择Run As - Maven clean 2.右击项目,选择Run As - Maven install 3.成功后 会在项目的target文件夹下生成jar包 4.将打包好的jar ...

  4. unix网络编程-配置unp.h头文件

    第一步进入:www.unpbook.com,下载unp的随书代码.新建一个目录,将压缩包拷贝到这一目录下面,然后将压缩包直接解压:tar -zxvf  压缩包名.tar.gz 完成上一步后,进入到un ...

  5. mysql 根据月份查找数据

  6. Vue之过滤器的使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. RTSP详解

    关于 RTSP. RTSP协议是一个非常类似HTTP协议的流控制协议.它们都使用纯文本来发送信息,而且rtsp协议的语法也和HTTP类似.Rtsp一开始这样设计,也是为了能够兼容使用以前写的HTTP协 ...

  8. 2018美赛准备之路——Matlab基础——命令行功能函数

    clc 清屏(只清除显示内容) clear  清除所有变量(运算结果) who  显示workspace的所有变量 whos  详细显示workspace的所有变量  help sin 显示sin函数 ...

  9. Spring中RestTemplate的使用方法

    一.REST 在互联网中,我们会通过请求url来对网络上的资源做增删改查等动作,这里的请求包含两部分:动词,主要包括增.删.改.查:名词,就是网络中的各种资源.传统的非REST风格的请求方式是把动词和 ...

  10. Python_编程题集_003_递归算法解析

    3.递归算法: 3)传入一个Json串,返回一个字典,字典只取出Json最底层的数据, 中间如果有字符串也要进行处理,请以下面的数据为例,请用递归方法实现 Json:{"a":&q ...