• Gym 100531J Joy of Flight (几何)


    题意:你从开始坐标到末尾坐标,要经过 k 秒,然后给你每秒的风向,和飞机的最大速度,问能不能从开始到末尾。

    析:首先这个风向是不确定的,所以我们先排除风向的影响,然后算出,静风是的最小速度,如果这都大于最大速度,肯定是不可能,如果可能,

    再计算出每秒走的单位长度,然后再模拟整个过程。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <cmath>
    #include <stack>
    #define debug puts("+++++")
    //#include <tr1/unordered_map>
    #define freopenr freopen("in.txt", "r", stdin)
    #define freopenw freopen("out.txt", "w", stdout)
    using namespace std;
    //using namespace std :: tr1;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const LL LNF = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 1e4 + 5;
    const LL mod = 1e3 + 7;
    const int N = 1e6 + 5;
    const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
    const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
    const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
    inline LL gcd(LL a, LL b){  return b == 0 ? a : gcd(b, a%b); }
    inline int gcd(int a, int b){  return b == 0 ? a : gcd(b, a%b); }
    inline int lcm(int a, int b){  return a * b / gcd(a, b); }
    int n, m;
    const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    inline int Min(int a, int b){ return a < b ? a : b; }
    inline int Max(int a, int b){ return a > b ? a : b; }
    inline LL Min(LL a, LL b){ return a < b ? a : b; }
    inline LL Max(LL a, LL b){ return a > b ? a : b; }
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    int t[maxn];
    double x[maxn], y[maxn];
    
    int main(){
        freopen("joy.in", "r", stdin);
        freopen("joy.out", "w", stdout);
        int sx, sy, fx, fy;
        while(scanf("%d %d %d %d", &sx, &sy, &fx, &fy) == 4){
            int k;
            scanf("%d %d %d", &n, &k, &m);
            for(int i = 1; i <= n; ++i)  scanf("%d %lf %lf", &t[i], &x[i], &y[i]);
            t[n+1] = k;
            double dx = fx - sx;
            double dy = fy - sy;
            for(int i = 1; i <= n; ++i){
                dx -= x[i] * (t[i+1] - t[i]);
                dy -= y[i] * (t[i+1] - t[i]);
            }
            if(hypot(dx, dy) > (double)m * k){
                puts("No");  continue;
            }
            puts("Yes");
            double vx = dx / k;
            double vy = dy / k;
            int pos = 0;
            double ansx = sx;
            double ansy = sy;
            for(int i = 1; i <= k; ++i){
                if(t[pos+1] < i) ++pos;
                ansx += x[pos] + vx;
                ansy += y[pos] + vy;
                printf("%f %f
    ", ansx, ansy);
            }
        }
        return 0;
    }
    
  • 相关阅读:
    CTFHub-Web-Web前置技能-HTTP协议-响应包源代码详解
    BurpSuite环境安装及设置
    i2 Analyst’s Notebook 9学习笔记之入门、基本概念和数据接口
    Python 练习题:用索引取出LIST中的值
    python 练习题:小明的成绩从去年的72分提升到了今年的85分,请计算小明成绩提升的百分点
    zabbix4.0 本地安装详解及步骤
    CentOS 7 安装 mysql 5.7.27 for zabbix
    win7系统 右击任务栏 资源管理器 弹出菜单“已固定”和“最近”项目不显示故障处理
    CentOS 7 新系统 手动配置网络 简要步骤
    CentOS7 firewalld防火墙 启动 关闭 禁用 添加删除规则等 常用命令
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5991398.html
Copyright © 2020-2023  润新知