注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

长风明志的博客

不要也不能做下一个谁,应该且可以做第一个自己

 
 
 

日志

 
 

【POJ 1045】 Bode Plot  

2013-03-26 22:15:51|  分类: ACM |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Description

Consider the AC circuit below. We will assume that the circuit is in steady-state. Thus, the voltage at nodes 1 and 2 are given by v1 = VS coswt and v2 = VRcos (wt + q ) where VS is the voltage of the source, w is the frequency (in radians per second), and t is time. VR is the magnitude of the voltage drop across the resistor, and q is its phase. 
【POJ 1045】 Bode Plot - changfengmingzhi - 长风明志的博客

You are to write a program to determine VR for different values of w. You will need two laws of electricity to solve this problem. The first is Ohm's Law, which states v2 = iR where i is the current in the circuit, oriented clockwise. The second is i = C d/dt (v1-v2) which relates the current to the voltage on either side of the capacitor. "d/dt"indicates the derivative with respect to t. 

Input

The input will consist of one or more lines. The first line contains three real numbers and a non-negative integer. The real numbers are VS, R, and C, in that order. The integer, n, is the number of test cases. The following n lines of the input will have one real number per line. Each of these numbers is the angular frequency, w

Output

For each angular frequency in the input you are to output its corresponding VR on a single line. Each VR value output should be rounded to three digits after the decimal point.

Sample Input

1.0 1.0 1.0 9
0.01
0.031623
0.1
0.31623
1.0
3.1623
10.0
31.623
100.0

Sample Output

0.010
0.032
0.100
0.302
0.707
0.953
0.995
1.000
1.000

这是一道极其简单的题目,主要考查的是对物理公式的求解推导:
公式推导:V2=iR=CR d/dt(Vs*cos(wt)-Vr*cos(wt+b))=Vrcos(wt+b)
          CRw(Vrsin(wt+b)-Vs*sin(wt))=Vr*cos(wt+b)
         令t=0化简得:   tan(b)=1/(CRw)-------------(1)
          令wt+b=0化简得:Vr=CRwVs*sin(b)------------(2)
           因为 sinb=sqrt(tanb^2/(1+tanb^2))
          由(1),(2)得:   Vr=CRwVs/sqrt(1+(CRw)^2))

///////源代码///////////////
//224K   0MS
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
	double Vs,R,C;
	int n;
	double w;
	double tempResult;
    vector<double> vec_input;
	while(cin>>Vs>>R>>C>>n)
	{
		while(n--)   //input the data
		{
			cin>>w;
			vec_input.push_back(w);
		}
		for(int i=0;i<vec_input.size();i++)  //output the result
		{
			tempResult=C*R*Vs*vec_input[i]/sqrt(1+pow(C*R*vec_input[i],2));
			cout<<setiosflags(ios::fixed)<<setprecision(3)<<tempResult<<endl;
		}
		vec_input.clear();
	}
	return 0;


}
  评论这张
 
阅读(262)| 评论(1)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017