poj 1045/3299 数学公式推导(欧姆定律/湿度值)

来源:互联网 发布:阿里云ubuntu中文乱码 编辑:程序博客网 时间:2024/06/10 01:36
题意:给出公式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))

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

#include <stdio.h>#include <math.h>int main(){    double u,r,c,w;    int k;    scanf("%lf %lf %lf %d",&u,&r,&c,&k);    while(k--){        scanf("%lf",&w);        printf("%.3lf\n",u*r*c*w*sqrt(1/(1+r*r*c*c*w*w)));    }    return 0;}

3299:题意:给定一个公式humidex = temperature + h
h = (0.5555)× (e - 10.0)

e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]

其中有三个参数:humidex,temperature,dewpoint,任意给出其中两个求第三个。

思路:只要给出D求另外两个就是简单套公式,如果求D,那么需要移项写出D的表达式。水题。

#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <cstdlib>using namespace std;#define clc(s,t) memset(s,t,sizeof(s))#define INF 0x3fffffff#define E 2.718281828double s[255];int main(){    char cmd[10];    double tmp;    while(scanf("%s",cmd) && strcmp(cmd, "E")){        s['T'] = s['D'] = s['H'] = 150;        scanf("%lf",&tmp);        s[cmd[0]] = tmp;        scanf("%s %lf",cmd,&tmp);        s[cmd[0]] = tmp;        tmp = 0.5555*( 6.11*pow(E, 5417.753/273.16*s['D']/(s['D']+273.16)) -10);        if(s['H'] == 150){            s['H'] = s['T']+tmp;        }else if(s['T'] == 150){            s['T'] = s['H']-tmp;        }else{            tmp = log((s['H']-s['T']+5.555)/(0.5555*6.11))/log(E);            s['D'] = 273.16*5417.753/(5417.753-tmp*273.16) - 273.16;        }        printf("T %.1lf D %.1lf H %.1lf\n",s['T'],s['D'],s['H']);    }    return 0;}


0 0