HZAU 1018 Catching Dogs
来源:互联网 发布:mysql ifnull不起作用 编辑:程序博客网 时间:2024/05/19 00:14
题目连接
模拟
#include<iostream> #include<cstdio> #include<cmath> using namespace std; const int maxn = 10 + 10; int n, v0; int v[maxn]; double p[maxn]; void solve() { double p0 = 0; double ans = 0; for(int i = 0; i < n; i++) scanf("%lf%d", &p[i], &v[i]); bool flag = true; for(int i = 0; i < n; i++){ if (v[i] == 0) { double t = abs(p0 - p[i])/v0; ans += t; p0 = p[i]; for(int j = i + 1; j < n; j++) p[j] += (v[j] * t); continue; } int s; if(p[i] == p0) s = 0; else if((p[i] - p0) * v[i] > 0) s = 1; // zhuiji else s = 2; //xiangyu if(s == 1 && abs(v[i]) >= v0) {flag = false; break;} double t; if(s == 1) { t = abs(p0 - p[i]) / (v0 - abs(v[i])); p0 += (v[i]/abs(v[i]) * t * v0); } else if(s == 2) { t = abs(p0 - p[i]) / (v0 + abs(v[i])); p0 -= (v[i]/abs(v[i]) * t * v0); } else t = 0; ans += t; for(int j = i + 1; j < n; j++) p[j] += (v[j] * t); } if(flag) printf("%.2lf\n", ans); else printf("Bad Dog\n"); } int main(){ //freopen("input.txt", "r", stdin); while(scanf("%d%d", &n, &v0) != EOF) solve(); }
0 0
- HZAU 1018 Catching Dogs
- HZAU--20--Catching Dogs(模拟)
- Problem I: Catching Dogs
- Problem I: Catching Dogs
- hzauoj Problem I: Catching Dogs (数学模拟)
- Problem I: Catching Dogs 几何水题
- 华中农业大学第四届程序设计大赛网络同步赛Problem I: Catching Dogs
- Problem I: Catching Dogs——华中农业大学第四届程序
- My dogs ...
- Dogs' Candies
- Apple Catching
- Catching Crabs
- Catching Fish
- Apple Catching
- Apple Catching
- HZAU 1000 Enrolling
- HZAU 1005 Balance
- HZAU 1003 Alien invasion
- POJ 3254 Corn Fields 状压DP
- ARP协议
- 接口测试及服务器性能压测
- Dynamics CRM2016 Web API之获取查找字段的text及选项集的text
- HDU1166 线段树
- HZAU 1018 Catching Dogs
- isight整数规划问题求解,用most算法
- [dp+数论]bzoj1004
- PPT1 例2
- 指针指向数组并指定数组首地址的一种方法
- UNIX网络编程:IPC之消息队列
- 验证码的发展史
- 解决对话框报错方案
- hdoj 2055 An easy problem (单个字符)