题目链接:https://vjudge.net/problem/Gym-102309C

题意:给定蔡徐坤投篮的位置和篮筐的位置以及最大初速度,求一个初速度和时间。

思路:一开始我以为要用到二分,后面仔细一想不用这么麻烦,题目限制了最大初速度,但又保证一定存在解,那么我们就直接可以用给定的初速度,然后解一个一元二次方程即可(为什么这样可以呢,学过物理的同学就很容易理解,总会找到一个角度与其速度大小和路线一一对应)。

简单的化简过程:

  1 #include <bits/stdc++.h>
2 #include <time.h>
3 #include <set>
4 #include <map>
5 #include <stack>
6 #include <cmath>
7 #include <queue>
8 #include <cstdio>
9 #include <string>
10 #include <vector>
11 #include <cstring>
12 #include <utility>
13 #include <cstring>
14 #include <iostream>
15 #include <algorithm>
16 #include <list>
17 using namespace std;
18 //cout<<setprecision(10)<<fixed;
19 #define eps 1e-6
20 #define PI acos(-1.0)
21 #define lowbit(x) ((x)&(-x))
22 #define zero(x) (((x)>0?(x):-(x))<eps)
23 #define mem(s,n) memset(s,n,sizeof s);
24 #define ios {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
25 typedef long long ll;
26 typedef unsigned long long ull;
27 const int maxn=1e6+5;
28 const int Inf=0x7f7f7f7f;
29 const ll mod=1e9+7;
30 //const int N=3e3+5;
31 bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }//判断一个数是不是 2 的正整数次幂
32 int modPowerOfTwo(int x, int mod) { return x & (mod - 1); }//对 2 的非负整数次幂取模
33 int getBit(int a, int b) { return (a >> b) & 1; }// 获取 a 的第 b 位,最低位编号为 0
34 int Max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }// 如果 a>=b,(a-b)>>31 为 0,否则为 -1
35 int Min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
36 ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
37 ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
38 int Abs(int n) {
39 return (n ^ (n >> 31)) - (n >> 31);
40 /* n>>31 取得 n 的符号,若 n 为正数,n>>31 等于 0,若 n 为负数,n>>31 等于 -1
41 若 n 为正数 n^0=n, 数不变,若 n 为负数有 n^(-1)
42 需要计算 n 和 -1 的补码,然后进行异或运算,
43 结果 n 变号并且为 n 的绝对值减 1,再减去 -1 就是绝对值 */
44 }
45 ll binpow(ll a, ll b) {
46 ll res = 1;
47 while (b > 0) {
48 if (b & 1) res = res * a%mod;
49 a = a * a%mod;
50 b >>= 1;
51 }
52 return res%mod;
53 }
54 void extend_gcd(ll a,ll b,ll &x,ll &y)
55 {
56 if(b==0) {
57 x=1,y=0;
58 return;
59 }
60 extend_gcd(b,a%b,x,y);
61 ll tmp=x;
62 x=y;
63 y=tmp-(a/b)*y;
64 }
65 ll mod_inverse(ll a,ll m)
66 {
67 ll x,y;
68 extend_gcd(a,m,x,y);
69 return (m+x%m)%m;
70 }
71 ll eulor(ll x)
72 {
73 ll cnt=x;
74 ll ma=sqrt(x);
75 for(int i=2;i<=ma;i++)
76 {
77 if(x%i==0) cnt=cnt/i*(i-1);
78 while(x%i==0) x/=i;
79 }
80 if(x>1) cnt=cnt/x*(x-1);
81 return cnt;
82 }
83 /*int main()
84 {
85 double x0,y0,x1,y1,v,vx,vy,t;
86 double g=9.80665;
87 while(cin>>x0>>y0>>x1>>y1>>v)
88 {
89 x1-=x0,y1-=y0;
90 if(x1==0)
91 {
92 t=(v+sqrt(v*v-2*g*y1))/g;
93 vx=0,vy=v;
94 }else{
95 t=sqrt(sqrt((x1*x1+y1*y1)*4/(g*g)));
96 vx=x1/t;
97 vy=(y1+g*t*t/2)/t;
98 }
99 cout<<setprecision(10)<<fixed;
100 cout<<vx<<" "<<vy<<" "<<t<<endl;
101 }
102 return 0;
103 }*/
104 int main()
105 {
106 double x0,y0,x1,y1,v,vx,vy,t,g=9.80665;
107 while(cin>>x0>>y0>>x1>>y1>>v)
108 {
109 x1-=x0,y1-=y0;
110 if(x1==0)
111 {
112 t=(v+sqrt(v*v-2*g*y1))/g;
113 vx=0,vy=v;
114 }
115 else
116 {
117 t=sqrt(((v*v-g*y1)-sqrt((g*y1-v*v)*(g*y1-v*v)-g*g*(x1*x1+y1*y1)))/(g*g/2));
118 vx=x1/t;
119 vy=(y1+g*t*t/2)/t;
120 }
121 cout<<fixed<<setprecision(10)<<vx<<" "<<vy<<" "<<t<<endl;
122 }
123 }

Cai Xukun and Orz Pandas Gym - 102309C的更多相关文章

  1. Another Array of Orz Pandas

    Another Array of Orz Pandas 题目链接:http://acm.xidian.edu.cn/problem.php?id=1187 线段树 线段树维护区间和以及区间内各个数平方 ...

  2. XidianOJ 1120 Gold of Orz Pandas

    题目描述 Orz Panda is addicted to one RPG game. To make his character stronger, he have to fulfil tasks ...

  3. XidianOJ 1195 Industry of Orz Pandas

    --正文 贪心 排序好慢慢找就好 #include <iostream> #include <cstring> #include <cstdio> #include ...

  4. 【Codeforces】Orz Panda Cup

    大大出的题 大大经常吐槽没有人补,所以我决定做一个 A. APA of Orz Pandas 题意:给你一个包含+-*/%和()的表达式,让你把它转化成java里BigInteger的形式 大概就像这 ...

  5. xdoj-1117(记忆化搜索+组合数学)

    因为我是从上到下,所以就不叫动态规划而叫记忆化搜索吧 (不过运行时间只有3ms....应该是很不错的吧) 排版怎么那么难看...编辑的时候不是这样子的啊?! 思想 : 大眼一看应该是一道很裸的状压dp ...

  6. codeforces gym #102082C Emergency Evacuation(贪心Orz)

    题目链接: https://codeforces.com/gym/102082 题意: 在一个客车里面有$r$排座位,每排座位有$2s$个座位,中间一条走廊 有$p$个人在车内,求出所有人走出客车的最 ...

  7. Codeforces Gym 100342C Problem C. Painting Cottages 转化题意

    Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

  8. Codeforces Gym 100463E Spies 并查集

    Spies Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Desc ...

  9. 利用 pandas 进行数据的预处理——离散数据哑编码、连续数据标准化

    数据的标准化 数据标准化就是将不同取值范围的数据,在保留各自数据相对大小顺序不变的情况下,整体映射到一个固定的区间中.根据具体的实现方法不同,有的时候会映射到 [ 0 ,1 ],有时映射到 0 附近的 ...

随机推荐

  1. TypeScript Version 23 Design Patterns

    TypeScript Version 23 Design Patterns TypeScript 设计模式 https://refactoring.guru/design-patterns/types ...

  2. git commit guidelines

    git-commit-guidelines AngularJS Development Setup Running Tests Coding Rules Commit Message Guidelin ...

  3. useful podcast

    useful podcast front end podcast https://shoptalkshow.com https://stackoverflow.blog/podcast/ SoundC ...

  4. css-next & grid layout

    css-next & grid layout css3 demo https://alligator.io/ @media only screen and (max-width: 30em) ...

  5. js webpack打包时保留指定注释

    optimization: { minimizer: [ new TerserJSPlugin({ terserOptions: { format: { comments: /(\s*#if)|(\s ...

  6. 多种转弯角度的PBN旁切转弯图例分析

    无论世界怎样变化,我们依然是有点阳光就灿烂.面对世界的未知,最好的状态是勇敢的去面对,努力的去生活. 今天我们继续来聊一下PBN旁切转弯. PBN转弯保护区的结构通常都与它们的转弯角度大小有关,转弯角 ...

  7. Python数据结构与算法_回文数(03)

    判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121输出: true 示例 2: 输入: -121输出: false解释: 从左向右读, ...

  8. SSL/TLS协议详解(中)——证书颁发机构

    本文转载自SSL/TLS协议详解(中)--证书颁发机构 导语 上一篇中,我们讨论了关于Diffie Hellman算法的SSL/TLS密钥交换.我们最终认为需要第三方来验证服务器的真实性,并提出了证书 ...

  9. 使用RSEM进行转录组测序的差异表达分析

    仍然是两年前的笔记 1. prepare-reference 如果用RSEM对比对后的bam进行转录本定量,则在比对过程中要确保比对用到的索引是由rsem-prepare-reference产生的. ...

  10. WPF 关于ComboBox在前台绑定XML数据的一些方法,使用XML数据提供器 XmlDataProvider

    关于使用 数据提供器:XmlDataProvider 的一些问题,以及在WPF中是如何使用的一些介绍,还有踩到的一些坑,希望其他和我碰到一样问题的,可以更快的解决. 首先,要求是 在WPF 的前台代码 ...