zoukankan      html  css  js  c++  java
  • 牛客网 Wannafly挑战赛3 B.遇见

    遇见

    时间限制:C/C++ 1秒,其他语言2秒
    空间限制:C/C++ 65536K,其他语言131072K
    64bit IO Format: %lld

    题目描述

    A和B在同一条路上,他们之间的距离为 k 米。A现在想见到B,所以A开车以 x km/h的速度朝着B的方向行驶,同时B也以 y km/h的速度朝着A的方向走去。A的车有 n 个档位,每个档位有不同的速度。现在假设A开车去见B,求他最快和最慢在几秒后能见到B。

    输入描述:

    一开始一行三个整数 n, m, k ,代表A的车的档位数、B行走的速度和AB之间的距离。
    接下来一行 n 个整数,代表A的车的不同档位的行驶速度。

    输出描述:

    一行两个整数,代表A最快/最慢在几秒后能见到B(向上取整)。
    示例1

    输入

    5 20 80
    30 15 10 5 -5

    输出

    6 20

    备注:

    对于所有数据,0 <= n <= 1000,-100000 <= A车速度 <= 100000,-A最慢速度 < B行走速度 <= 100000,0 <= k <= 100000.
    题目保证最大值和最小值都有解。



    代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 const int N=1e5+10;
     4 const double INF=0x3f3f3f3f;
     5 const double  eps=1e-6;
     6 typedef long long ll;
     7 double a[N];
     8 int main(){
     9     double n,m,k;
    10     double minn,maxx;
    11     double ansmax,ansmin;
    12     while(~scanf("%lf%lf%lf",&n,&m,&k)){
    13         minn=INF;maxx=-INF;
    14         for(int i=0;i<n;i++){
    15             scanf("%lf",&a[i]);
    16             minn=min(minn,a[i]);
    17             maxx=max(maxx,a[i]);
    18         }
    19         if(n==0)maxx=0,minn=0;
    20         ansmax=k*36/((maxx+m)*10);
    21         ansmax=ceil(ansmax);
    22         ansmin=k*36/((minn+m)*10);
    23         ansmin=ceil(ansmin);
    24         printf("%.0f %.0f
    ",ansmax,ansmin);
    25     }
    26     return 0;
    27 }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  • 相关阅读:
    RabbitMQ知识点整理12-消费端的确认与拒绝
    RabbitMQ知识点整理11-消费消息
    RabbitMQ知识点整理0-准备工作和记录
    设计模式-23种设计模式
    设计原则-6大设计原则
    super在python 2.7和Python3中的使用
    rest-framework 视图类源码分析
    celery 组件在django环境应用
    rest framwork 4 分页功能
    rest framework 学习 序列化
  • 原文地址:https://www.cnblogs.com/ZERO-/p/8052603.html
Copyright © 2011-2022 走看看