题解 P4710 【「物理」平抛运动】

· · 题解

物理小知识


题目已经给出了速度分解的方法
易得 \theta=\angle1 ,则 \sin \theta=a:b ,b=v 所以 v\sin\theta=a
同理可得 \cos\theta=c:b ,v\cos\theta=c
我们就可以分解出质点砸到点 (0,0) 的速度。

解法

其中水平方向上的速度 v_x 即为抛出速度,运动过程中一直为 v\sin\theta。
意思就是分解出的 v_x 就是抛出时的速度啦。
抛出时的横坐标 x_0 就是 v_xt。
那么时间t怎么求呢?
根据 tg=v_y (g为重力加速度)可得 t=\dfrac{v_y}{g}。
求出 t 后代入即可算出 x_0。
根据题目给的公式 y_0=\frac{1}{2}gt^2 即可算出 y_0。

code

#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
double v,O;
int main(){
    cin>>v>>O;
    double vx,vy;
    vx=sin(O)*v; //给的是弧度制,就直接调用
    vy=cos(O)*v;
    double t;
    t=vy/10.0;  //注意这里的10.0和下面的2.0一样,要加上一位小数,否则除完会被强制类型转换
    double ansx,ansy;
    ansx=t*vx;
    ansy=t*vy/2.0;
    printf("%.15lf %.15lf",ansx,ansy);  //保留15位小数
}