POJ 1852 Ants O(n)
来源:互联网 发布:java中类属变量是什么 编辑:程序博客网 时间:2024/06/05 13:27
题目:
思路:蚂蚁相碰和不相碰的情况是一样的,相当于交换位置继续走。
代码:
#include <iostream>#include <cstdio>#include <math.h> using namespace std;typedef long long ll;int main() { int t; int l,n; int key; int low,high; cin >> t; while(t--){ cin >> l >> n; int mn = 0; int mx = 0; for(int i = 0;i < n; i++){ scanf("%d",&key); if(key < l/2){ low = key; high = l-key; }else{ low = l-key; high = key; } mn = max(low,mn); mx = max(high,mx); } cout << mn << " " << mx << endl; } return 0;}// writen by zhangjiuding
阅读全文
0 0
- POJ 1852 Ants O(n)
- poj 1852 Ants
- POJ 1852 Ants
- poj 1852Ants
- POJ 1852 Ants 蚂蚁
- POJ 1852 Ants
- POJ 1852 Ants
- POJ-1852-Ants
- POJ 1852 Ants
- [ACM] POJ 1852 Ants
- POJ 1852 Ants
- POJ 1852 Ants 模拟
- POJ 1852 ANTS
- poj 1852 ants
- POJ 1852 Ants
- POJ 1852 Ants
- POJ 1852 Ants
- POJ 1852 Ants
- Prim算法实现最小生成树
- laravel5日志设置篇(2/3) – 记录sql日志
- LVM基本概念及管理
- JVM之垃圾收集算法
- eclipse创建maven项目报Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:2.
- POJ 1852 Ants O(n)
- 用反射、注解及DBUtils对Dao层抽取
- zk的watcher机制
- 51nod 1268 和为K的组合 dfs
- 【编译原理】词法分析(三)
- 【工具】如何在使用pc上的pycharm远程调试Ubuntu服务器上的python工程
- java虚拟机中的invokevirtual所造成的问题
- Arcpy查找指定用户的所有要素类并列举其属性信息
- POJ 2386 Lake Counting dfs