poj-1045(数学不好怪我咯)

     

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.

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

题意:给出公式V2=iR,V2=Vr * cos(wt + q), V1=Vs * cos(wt), i = C * d(v1 - v2)/dt; d是求导数的意思。已知Vs,R,C,w,求Vr。

分析:利用V2分别等于两个式子,将i,V2和V1带入,可得方程:R*C*d(Vs * cos(wt) - Vr * cos(wt + q))/dt  = Vr * cos(wt + q)

根据求导公式:d(cos(x))/dx = -sinx可将原方程化为:R*C*w*(Vr*sin(wt + q) - Vs*sin(wt)) = Vr * cos(wt + q)

在这里三角函数的参数有两个:wt+q和wt,我们分别令他们为0,方程分别可变为:R*C *w*Vs*sin(q) = Vr; R*C * w*sin(q) = cos(q)

由2式得:cot(q) = R * C * w。

由公式:sin^2(a) = 1/(cot ^2(a) + 1)

可得:sin(q)=sqrt(1/(cot^2(q) + 1))

即:sin(q) =sqrt(1/(R^2*C^2*w^2 + 1))

#include<iomanip>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{

    double vs,r,c,w;
    int n;
     cin>>vs>>r>>c>>n;
    while(n--)
    {
       cin>>w;
       cout<<fixed<<setprecision(3)<<r*c*w*vs*sqrt(1/(r*r*c*c*w*w+1))<<endl;
    }

    return 0;
}

  

代入1式可得:Vr = R * C * w * Vs * sqrt(1/(R^2*C^2*w^2 + 1))

				
时间: 2025-01-03 20:06:27

poj-1045(数学不好怪我咯)的相关文章

24、英语数学不好,可以学PHP吗?

英语不好,并不会影响PHP的学习,因为PHP常用英文也就那么几个. 不信,可以百度一篇帖子<新手别怕:学PHP涉及的所有英文单词,也就这么几部分>. 但是如果数学不好,也不同担心,只要掌握基本的数学逻辑,学习PHP也是没有什么问题的. 详情请见单词汇总系列 html http://www.cnblogs.com/xin880/p/8022310.html css http://www.cnblogs.com/xin880/p/8022314.html js http://www.cnblogs

CF J. Superfactorial numeral system 我知道你数学不好...

数学是吧!!把老娘的意大利炮拿过来 给数学看看 J. Superfactorial numeral system 这题可以看出来,要是p/q大于0的话,那就没有后面的分母为2!.3!.4!...的阶乘什么事了 它直接等于a1 所以我们就从2开始乘 2*3*4*5*----*n 也就是(n*----*5*4*3*2*p/q)这个一次 然后就,输出p/q is ok~ 代码等会再写~~~ 具体的还有一点小细节~little details~~~~ 原文地址:https://www.cnblogs.c

POJ 2906 数学期望

开始时直接设了一个状态,dp[i][j]为发现i种bug,j个系统有bug的期望天数.但很错误,没能转移下去.... 看了题解,设状态dp[i][j]为已发现i种bug,j个系统有bug,到完成目标状态所需要的期望的天数.妙啊,这样一设状态,就很好更解了.如,由dp[i][j] 可以到达状态dp[i][j+1],则到达它的概率很明显可求出为p=(i/n)*((s-j)/s),则是,需要dp[i][j+1](期望)天数的概率就是p.这就很容易理解了啊,高!高!高! 由dp[i][j]可以转移出四个

BL老师的建议,数学不好的,大数据一票否决

POJ 1045

#include<iostream> #include<cmath> #include<iomanip> using namespace std; int main() { //freopen("acm.acm","r",stdin); double vs; double r; double c; double w; int n; cin>>vs>>r>>c>>n; while(n

Dead Fraction POJ 1930(数学)

原题 题目链接 题目分析 无限循环小数化分数.把小数用分数表示,后面等比数列可以用求和公式化简,最后可以总结出一个通用公式(可以百度),这里不细讲.需要注意一下,题目没有明确说明循环部分从哪开始,因此需要枚举循环部分,找到分母最小的输出即可. 代码 1 #include <iostream> 2 #include <algorithm> 3 #include <utility> 4 #include <cstdio> 5 #include <cstdl

POJ 1850 Code 数位DP

据说又是一道组合数学题,数学不好的我只想出的DP写法 注意如果输入不合法要输出0 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #include <string> #include <iostream> #include <map> #include <cstdli

POJ 1182 食物链(并查集)

食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 53651   Accepted: 15730 Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同

写给英语和数学都不怎么好的游戏开发爱好者

[来信] 贺老师你好,我想学习C ,以后成为一名游戏开发员,可是我的英文和数学都不怎么好.我不知道该怎么办,从哪里学起,但是我确信这是我可以为之奋斗一生的事业. [回信] 你的来信,没有给我讲起你的专业.年级等基本信息,不便于针对你的实际,给出我的看法.英语和数学,的确是从事IT行业很重要的素养,然而,却也并不是由于英语.数学不好,便一定不能有其中有所作为. 对于一名尚在发展中的学子而言,最重要的,是让自己的英语.数学好起来,"英语和数学"不怎么好既然不成为前提,这件事情也就解决了.而