poj 1852 ants(模拟+想象力)
来源:互联网 发布:java程序员做什么 编辑:程序博客网 时间:2024/05/16 05:55
题意是有一群蚂蚁在一根水平的棒棒上,告诉你棒棒的长度以及蚂蚁的位置,蚂蚁开始时的行动方向可任意。
求全部蚂蚁从水平棒棒上掉下来的最长时间和最短时间。
想象力,蚂蚁对头碰改方向想象成蚂蚁直接穿过了对方的身体。
代码:
#include <iostream>#include <algorithm>using namespace std;int x[1000000];int n, l;int main(){ int ncase; cin >> ncase; while (ncase--) { cin >> l >> n; for (int i = 0; i < n; i++) cin >> x[i]; // 计算最短时间 int minT = 0; for (int i = 0; i < n; i++) { minT = max(minT, min(x[i], l - x[i])); } // 计算最长时间 int maxT = 0; for (int i = 0; i < n; i++) { maxT = max(maxT, max(x[i], l - x[i])); } cout << minT << " " << maxT << endl; } return 0;}
0 0
- poj 1852 ants(模拟+想象力)
- 《挑战程序设计江赛》P18 题目:Ants POJ 1852 需要想象力的模拟
- POJ 1852 Ants 模拟
- POJ 1852 Ants(模拟+弹性碰撞)
- Ants(POJ 1852)
- POJ 1852 Ants (贪心)
- POJ 1852 Ants(机智)
- poj 1852 脑洞大开(Ants)
- POJ 1852 Ants (贪心)
- POJ 1852 Ants(思维)
- poj 1852 Ants(贪心)
- Ants(POJ NO.1852)
- poj1852 Ants (模拟)
- Ants(POJ No.1852) 脑筋急转弯
- POJ 1852 Ants (思维技巧 + 贪心)
- poj -1852 ants (思维题)
- poj Ants 1852 (简单数学规律)
- 【POJ】1852 - Ants(数学问题,思路)
- 内存泄露错误
- Mac 下 Chrome多个Tab之间切换
- 第一篇:知识库,Apache Jena,DL,Description Logic,Ontology。
- 监控 Linux 性能的 18 个命令行工具(转)
- 后缀数组+二分poj3261
- poj 1852 ants(模拟+想象力)
- Android exploit with a Qualcomm processor (CVE-2012-4220)
- 关键词抽取简介
- 【RT-Thread】——GUI服务器
- State pattern (sencode day)
- iphone面试笔试题目
- jQuery Timepicker Addon
- CXF Spring 基于契约优先开发
- Struts2配置文件讲解