题意: 一看图就明白了 要求的是1与n端点间的等效电阻

重点在于转化成考虑电流

根据KCL定理:在任一瞬间流出(流入)该节点的所有电流的代数和恒为零

       U = IR

 可以令1点的电势为零 那么n点的电势就等于它的等效电阻

可以列出方程组  $\sum\limits \frac{U_j-U_i}{R_ij} + I = 0$

         $U_0$ = 0;

 double a[][];  // 增广矩阵
double x[]; // 解
int free_x[]; // 标记是否为自由未知量 void Gauss(int n, int m) // n个方程 m个未知数 即 n行m+1列
{
//转换为阶梯形式
int col=, k;
for(k=;k<n && col<m;k++, col++)
{//枚举行
int max_r=k;
for(int i=k+;i<n;i++)//找到第col列元素绝对值最大的那行与第k行交换
if(fabs(a[i][col])>fabs(a[max_r][col]))
max_r=i;
if(fabs(a[max_r][col])<eps)
return ;
if(max_r!=k)// 与第k行交换
{
for(int j=col;j<m;j++)
swap(a[k][j], a[max_r][j]);
swap(x[k], x[max_r]);
}
x[k]/=a[k][col];
for(int i=col+;i<m;i++)
a[k][i]/=a[k][col];
a[k][col]=;
for(int i=;i<m;i++)
if(i!=k)
{
x[i]-=x[k]*a[i][k];
for(int j=col+;j<m;j++)
a[i][j]-=a[k][j]*a[i][col];
a[i][col]=;
}
}
} void init()
{
memset(a, , sizeof(a));
memset(x, , sizeof(x));
} int main()
{
int T, ca=;
scanf("%d", &T);
while(T--)
{
int n, m;
scanf("%d%d", &n, &m);
init();
for(int i=;i<m;i++)
{
int X, Y, Z;
scanf("%d%d%d", &X, &Y, &Z);
X--, Y--;
a[X][Y]+=1.0/Z;
a[Y][X]+=1.0/Z;
a[X][X]-=1.0/Z;
a[Y][Y]-=1.0/Z;
}
printf("Case #%d: ", ca++);
fill(a[n-], a[n-]+n, );
a[n-][]=;
x[]=;
Gauss(n, n);
printf("%.2lf\n", x[n-]);
}
return ;
}

HDOJ 3976

[Gauss]HDOJ3976 Electric resistance的更多相关文章

  1. HDU 3976 Electric resistance (高斯消元法)

    Electric resistance Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  2. [HDU3976]Electric resistance(电阻)(信竞&物竞)(高斯消元)

    题面 Problem Description Now give you a circuit who has n nodes (marked from 1 to n) , please tell abc ...

  3. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  4. poj 3532 Resistance

    ---恢复内容开始--- Resistance Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 1289   Accepte ...

  5. OPEN CASCADE Gauss Least Square

    OPEN CASCADE Gauss Least Square eryar@163.com Abstract. The least square can be used to solve a set ...

  6. OpenCASCADE Gauss Integration

    OpenCASCADE Gauss Integration eryar@163.com Abstract. Numerical integration is the approximate compu ...

  7. The Non-Inverting Amplifier Output Resistance by Adrian S. Nastase [ Copied ]

    Source Address: http://masteringelectronicsdesign.com/the-non-inverting-amplifier-output-resistance/ ...

  8. ural 1143. Electric Path

    1143. Electric Path Time limit: 1.0 secondMemory limit: 64 MB Background At the team competition of ...

  9. C# 列主元素(Gauss)消去法 计算一元多次方程组

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

随机推荐

  1. oracle添加表字段跟修改表字段属性

    添加字段 alter table mid_contactinfo add(status varchar(20),createdate varchar(50),modifydate varchar(50 ...

  2. sql查询某段时间内的数据

    查询半小时内数据的方法 1.select * from 表名 where datediff(minute,createtime,getdate())<30 2.select * from 表名 ...

  3. Html5 Video 实现方案

    来源:http://ask.dcloud.net.cn/article/569 源码下载 前言: 最近项目中需要用到html5 视频播放功能,于是稍微研究了解了下,遇到了很多坑,特此记录下. 一. H ...

  4. ASP.Net Core 运行在Linux(CentOS)

    Linux Disibutaion:CentOS 7.1 Web Server:Apache.Kestrel 1.安装.net core sudo yum install libunwind libi ...

  5. Microsoft SQL Server Product Samples:Database

    从SQL Server 2005 之后示例数据都为AdventureWorks,需要的通过codeplex网站下载.这样设计的目的应该在于是生产库行不必要的用户以及权限分配. 从以下网址访问http: ...

  6. 【MySQL】MySQL中针对大数据量常用技术_创建索引+缓存配置+分库分表+子查询优化(转载)

    原文地址:http://blog.csdn.net/zwan0518/article/details/11972853 目录(?)[-] 一查询优化 1创建索引 2缓存的配置 3slow_query_ ...

  7. Android系统简介(中):系统架构

    Android的系统架构栈分为4层,从上往下分别是Applications.Application framework.Libraries  & Android Runtime.Linux  ...

  8. 不显示UITableView底部多余的分割线

    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

  9. [MAXscript Tool]TimeSlider v1.3

    一个简单的小工具,方便在MAX里面快速的修改帧速率,像maya一样.具体看视频演示.

  10. Flexbox介绍

    CSS3 弹性盒( Flexible Box 或 flexbox),是一种当页面需要适应不同的屏幕大小以及设备类型时确保元素拥有恰当的行为的布局方式.对于很多应用来讲,弹性盒改进了盒模型,既不使用浮动 ...