zoukankan      html  css  js  c++  java
  • PAT 天梯赛 L3-013. 非常弹的球 【物理】

    题目链接

    https://www.patest.cn/contests/gplt/L3-013

    思路
    将速度 分解成 竖直方程 和 垂直方向
    当 角度为 45° 时 射出的时候 水平方向 最远
    所以 可以将 竖直方向的速度 和 垂直方向的速度是一样的
    然后 每次循环 算出 速度和时间
    更新答案
    然后 界定一个 阈值 跳出 就可以

    AC代码

    #include <cstdio>
    #include <cstring>
    #include <ctype.h>
    #include <cstdlib>
    #include <cmath>
    #include <climits>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <deque>
    #include <vector>
    #include <queue>
    #include <string>
    #include <map>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <sstream>
    #include <iomanip>
    #include <limits>
    
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef pair <int, int> pii;
    typedef pair <ll, ll> pll;
    typedef pair<string, int> psi;
    typedef pair<string, string> pss;
    
    const double PI  = 3.14159265358979323846264338327;
    const double E   = exp(1);
    const double eps = 1e-6;
    const double G   = 9.8;
    
    const int INF  = 0x3f3f3f3f;
    const int maxn = 1e6 + 5;
    const int MOD  = 1e9 + 7;
    
    int main()
    {
        int w, p;
        scanf("%d%d", &w, &p);
        double m = 1000.0;
        double sun = p * 1.0 / 100;
        sun = 1 - sun;
        double weight = w * 1.0 / 100;
        double ans = 0.0;
        while (1)
        {
            double v = sqrt(m * 1.0 / weight);
            double t = 2 * v / G;
            m *= sun;
            ans += v * t;
            if (t < eps)
                break;
        }
        printf("%.3lf
    ", ans);
    }
  • 相关阅读:
    SAP SD 模块面试题
    商品ATP check FM(获得可用库存和总库存)
    获得SO的凭证流
    SAP XI 常用事务代码
    ABAP 面试问题及答案(一)(转)
    ABAP 面试题(转)
    SAP XI 3.0考试大纲
    Enterprise System Applicaiton 试题
    Enterprise Portal 试题
    ABAP 100 道面试题
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433232.html
Copyright © 2011-2022 走看看