题意:

给出一个由n个节点和m个二元电阻元件组成的电路,求问节点1到节点n的等效电阻。

解法:

应用电子电路分析中的基尔霍夫定律,对于每一个点有流量平衡,得

对于点$x$有 $$I_{出} + \sum_{<i,x>∈|E|}{\frac{U_x-U_i}{R_{x,i}}} = I_{入}$$

规定从点1流入$1A$的电流,从点n流出$1A$的电流,得到n个关于$U_i$的方程。

注意到n个方程最大线性无关组为 n-1个方程,解出来是$x = k* \eta + \xi$,从而要引入一个新的方程。

(因为限制流入1的电流是$1A$的方程是多余的)

只要将点1的方程改成 $U_1 = 0V$ 即可。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath> #define N 110
#define LD double
#define eps 1e-13 using namespace std; int n,m,tot;
LD u[N],a[N][N]; LD Gauss(LD a[N][N],int n)
{
int cnt=;
for(int i=;i<=n;i++)
{
int t=;
for(int j=i;j<=n;j++)
if(fabs(a[j][i])>eps)
{
t=j;
break;
}
if(!t)
{
cnt++;
continue;
}
for(int j=;j<=n+;j++) swap(a[i][j],a[t][j]);
for(int j=i+;j<=n+;j++) a[i][j]/=a[i][i];
a[i][i]=1.0;
for(int j=;j<=n;j++)
{
if(j==i) continue;
for(int k=i+;k<=n+;k++)
a[j][k] -= a[j][i]*a[i][k];
a[j][i]=;
}
}
return a[n][n+]/a[n][]- a[][n+]/a[][n];
} int main()
{
// freopen("test.txt","r",stdin);
while(~scanf("%d%d",&n,&m))
{
memset(a,,sizeof(a));
int x,y;
LD R;
for(int i=;i<=m;i++)
{
scanf("%d%d%lf",&x,&y,&R);
LD tmp=1.0/R;
a[x][x]+=tmp;
a[y][y]+=tmp;
a[x][y]-=tmp;
a[y][x]-=tmp;
}
a[][]=;
for(int i=;i<=n;i++) a[][i]=;
a[][n+]=;
a[n][n+]=;
printf("%.2f\n",Gauss(a,n));
}
return ;
}

Resistance的更多相关文章

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

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

  2. codeforces343A A. Rational Resistance

    http://http://codeforces.com/problemset/problem/343/A A. Rational Resistance time limit per test 1 s ...

  3. Codeforces Round #200 (Div. 1)A. Rational Resistance 数学

    A. Rational Resistance Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343 ...

  4. New Lantern Version Available Upgrade Lantern for improved blocking resistance!

    New Lantern Version Available Upgrade Lantern for improved blocking resistance! The new version: is ...

  5. hug and Compression Resistance

    Hugging => content does not want to grow Compression Resistance => content does not want to sh ...

  6. AutoLayout学习之理解intrinsicContentSize,Content Hugging Priority,Content Compression Resistance Priority

    TableViewCell的高度计算应该是所有开发者都会使用到的东西,之前都是用代码计算的方法来计算这个高度.最近有时间看了几个计算Cell高度的方法.基本上都用到了AutoLayout,这篇首先介绍 ...

  7. Codeforces Round #200 (Div. 2) C. Rational Resistance

    C. Rational Resistance time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. iOS开发之AutoLayout中的Content Hugging Priority和 Content Compression Resistance Priority解析

    本篇博客的内容也不算太复杂,算是AutoLayout的一些高级的用法.本篇博客我们主要通过一些示例来看一下AutoLayout中的Content Hugging Priority以及Content C ...

  9. The Non-Inverting Amplifier Output Resistance by Adrian S. Nastase [转载]

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

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

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

随机推荐

  1. mysqldump导入导出详解

    mysqldump可以指定路径的,如果没指定路径,而只写了文件名的话,那么就在当前进入mysql命令行所在的目录,也就是mysql安装目录下 mysqldump  --default-characte ...

  2. HDMI速率计算

    我们在采集HDMI口的数据时,首先肯定要计算它的速率是多少.怎么计算这个速率,本文要跟大家分享的便是这个事情. HDMI口有三个TM-DS(Time Minimized Differential Si ...

  3. 如何设置快捷键(File Search)

    window->preferences->General->keys. 找到File Search(有搜索框的,可以搜索),然后在下方 Binding按下ctrl +h .

  4. PS 魔法棒

    魔术棒工具是通过选取图像中颜色相近或大面积单色区域的像素来制作选区,魔术棒用于纯色背景中较多. 容差数值越大,选择出的选区就越大,容差越小,对颜色差别的要求也就越严格,选择出的选区也就越小 按住shi ...

  5. Apache Server与多个独立Tomcat集成

    取经自http://www.ramkitech.com/2012/03/virtual-host-apache-httpd-server-tomcat.html 继续干Tomcat和Apache Se ...

  6. UVA - 1045 The Great Wall Game(二分图最佳完美匹配)

    题目大意:给出棋盘上的N个点的位置.如今问将这些点排成一行或者一列.或者对角线的最小移动步数(每一个点都仅仅能上下左右移动.一次移动一个) 解题思路:暴力+二分图最佳完美匹配 #include < ...

  7. mysql 中的增改查删(CRUD)

    增改查删可以用CURD来表示  增加:create  修改:update   查找:read      删除:delete 增加create :  insert +表名+values+(信息): in ...

  8. SAM4E单片机之旅——6、LED闪烁之按钮控制

    现在试试用按钮控制LED灯……让LED在一个按钮按下时亮起:弹起时灭掉. 主要目的是学习GPIO的输入及中断. 一. 电路 图中的J39-n是几个跳线插座,位置在开发板LCD附近,往下进行前要先确保跳 ...

  9. Storage Types and Storage Policies

    https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/ArchivalStorage.html Introduc ...

  10. signal( SIGINT, SigIntHandler )

    signal 的第1个参数signum表示要捕捉的信号,第2个参数是个函数指针,表示要对该信号进行捕捉的函数,该参数也可以是SIG_DEF(表示交由系统缺省处理,相当于白注册了)或SIG_IGN(表示 ...