题意:

给出一个由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. c语言-递推算法1

    递推算法之一:倒推法 1.一般分析思路: if 求解初始条件F1 then begin { 倒推 } 由题意(或递推关系)确定最终结果Fn; 求出倒推关系式Fi-1 =G(Fi ); i=n; { 从 ...

  2. Linux上mysql修改密码

    http://www.cnblogs.com/wangjiangze/archive/2011/03/03/1970105.html   MySQL中修改密码及访问限制设置详解

  3. URL 截取参数 正则

    用处很多,记录下. function getvl(name) { var reg = new RegExp("(^|\\?|&)"+ name +"=([^&am ...

  4. 【ZZ】Visual C++ 6.0 精简安装版(支持VA、ICC 等等安装)

    (2012-04-22 08:10:10) 标签: it 分类: 软件_Software Visual C++ 6.0 精简安装版(支持VA.ICC 等等安装) 2012-04-16 21:07 想找 ...

  5. OpenCV 入门示例之二:播放 AVI 视频

    前言 本文展示一个播放 AVI 视频的程序.( 呵呵是 AVI 视频不是 AV 视频噢! ) 代码示例 // 此头文件包含图像IO函数的声明 #include "highgui.h" ...

  6. 对H.264帧类型判断方法

    背景描述 我们经常在网络直播推流或者客户端拉流的时候,需要对获取到的H.264视频帧进行判断后处理,我们经常获取到各种不同的视频数据0x67 0x68 0x65 0x61,0x27 0x28 0x25 ...

  7. EasyPusher实现将asterisk直播流以RTSP转发实现通话直播与录像

    本文转自博客:http://blog.csdn.net/jinlong0603/article/details/56047145 EasyPusher RTP直播推送介绍 EasyPusher是一个推 ...

  8. Avro schemas are defined with JSON . This facilitates implementation in languages that already have JSON libraries.

    https://avro.apache.org/docs/current/ Introduction Apache Avro™ is a data serialization system. Avro ...

  9. [eMMC]eMMC读写性能测试

    读写速率(dd) https://www.shellhacks.com/disk-speed-test-read-write-hdd-ssd-perfomance-linux/ eMMC健康情况(mm ...

  10. The PageFactory

    The PageFactory 原文地址:https://github.com/SeleniumHQ/selenium/wiki/PageFactory In order to support the ...