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\n", ansx, ansy);
}
}
return 0;
}
Gym 100531J Joy of Flight (几何)的更多相关文章
- Codeforces Gym 100531J Joy of Flight 变换坐标系
Joy of Flight 题目连接: http://codeforces.com/gym/100531/attachments Description Jacob likes to play wit ...
- gym 101081 E. Polish Fortress 几何
E. Polish Fortress time limit per test 2.0 s memory limit per test 256 MB input standard input outpu ...
- Why We Worry and What to Do About It
Note: My new book Atomic Habits is available to preorder now. Click here to learn more. The Evolutio ...
- codeforces Gym 100187B B. A Lot of Joy
B. A Lot of Joy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/proble ...
- Codeforces Gym 100269F Flight Boarding Optimization 树状数组维护dp
Flight Boarding Optimization 题目连接: http://codeforces.com/gym/100269/attachments Description Peter is ...
- 【Gym - 101124A】The Baguette Master (数学,几何)
BUPT2017 wintertraining(15) #4F Gym - 101124A 题意 给定画框宽度,画的四边和一个对角线长度,求画框外沿周长. 题解 过顶点做画框的垂线,每个角都得到两个全 ...
- Gym - 100269F Flight Boarding Optimization(dp+树状数组)
原题链接 题意: 现在有n个人,s个位置和你可以划分长k个区域你可以把s个位置划分成k个区域,这样每个人坐下你的代价是该区域内,在你之前比你小的人的数量问你怎么划分这s个位置(当然,每个区域必须是连续 ...
- On the way to the park Gym - 101147I 几何
http://codeforces.com/gym/101147/problem/I I. On the way to the park time limit per test 5 seconds m ...
- Gym 100187B-A Lot of Joy
题意:给一个字符串,将每个字符分开放进两个口袋,每次从两个口袋分别拿出一个字符,如果相同则开心,问开心的次数期望是多少. 分析:数学期望题,然而这是我最不拿手的...最后答案是每个字符在字符串出现的次 ...
随机推荐
- 【POJ1185】炮兵阵地(状压DP)
题意: 思路:状压DP经典题 可以预处理下每一行内合法的状态,发现很少 所以转移时可以使用状态的编号而不是状态本身 DP时记录前两行状态的编号进行转移和判断 #include<cstdio> ...
- boost thread 在非正常退出时 内存泄露问题
在使用boost的thread库的时候,如果主程序退出,thread创建的线程不做任何处理,则会出现内存泄露. 解决方法: 在主线程退出时,对所有thread使用interrupt()命令,然后主程序 ...
- Palindrome Partitioning (回文子串题)
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- top命令行含义解析
快捷键“1”可以快速切换显示所有cpu的信息 快捷键‘x’可以高亮显示当前排序列 shift+方向键:可以快速切换排序的列 top -c 显示完整命令 load含义解释:http://www.ruan ...
- linux用户列表
centos上面不知道添加了多少个账户,今天想清理一下,但是以前还未查看过linux用户列表, 一般情况下是 cat /etc/passwd 可以查看所有用户的列表 w 可以查看当前活跃的用户列表 c ...
- [javase学习笔记]-9.2 单继承与多重继承
这一节我们来看java中的单继承和多重继承. 在java语言中,支持的是单继承,不直接支持多继承,可是对C++中的多继承进行了改良. 那么什么是单继承和多继承呢? 单继承:一个子类仅仅能有一个直接父类 ...
- JavaSE----API之集合(Collection、List及其子类、Set及其子类、JDK1.5新特性)
5.集合类 集合类的由来: 对象用于封装特有数据,对象多了须要存储:假设对象的个数不确定.就使用集合容器进行存储. 集合容器由于内部的数据结构不同,有多种详细容器.不断的向上抽取,就形成了集合框架. ...
- 关于Android中物理按键不响应的可能的一个问题。
今天在工作中犯了一个错误,写的视频播放器突然物理音量键就不起作用了. 一開始以为是自己定义的音量条把系统的物理音量条按键给屏蔽掉了. 删除自己定义的音量条还是不行,又怀疑是是加入了什么权限之类的.重复 ...
- AngularJS 基础入门(指令篇)
一.介绍 AngularJS 是google 开发人员设计的一个前端开发框架,它是由是由javascript 编写的一个JS框架.通常它是用来在静态网页构建动态应用不足而设计的. AngularJS特 ...
- Selenium 工具介绍、安装、配置及使用
概念 selenium是一款跨平台开源工具,用于web的功能完整性測试,想做压力測试的能够换软件了 先看一眼官方站 http://docs.seleniumhq.org/download/ 首先要FQ ...