51nod 1266 蚂蚁
蚂蚁这道题 就是 不管两只蚂蚁相撞 他们会朝自己的反方向走
不过可以这么想 有蚂蚁1 和 蚂蚁2 并且相向而行
如果撞了以后 蚂蚁1和蚂蚁2 就往回走 ,这里可以理解成蚂蚁1,蚂蚁2 继续朝自己的方向走
因为我们是不关心 具体蚂蚁的到达哪个端点的
#include <bits/stdc++.h>
using namespace std; int main ()
{
int n,L;
cin >> n >> L;
int ans1= ,ans2=;
for(int i=;i<=n;i++)
{
int x;cin >> x;
int mx = min(x,L-x);
int Mx = max(x,L-x);
ans2 = max(Mx,ans2);
ans1 = max(mx,ans1);
}
cout << ans1<<" "<<ans2<<endl; }
51nod 1266 蚂蚁的更多相关文章
- 【51Nod 1244】莫比乌斯函数之和
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1244 模板题... 杜教筛和基于质因子分解的筛法都写了一下模板. 杜教筛 ...
- 51Nod 1268 和为K的组合
51Nod 1268 和为K的组合 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使 ...
- 51Nod 1428 活动安排问题
51Nod 1428 活动安排问题 Link: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428 1428 活 ...
- 51Nod 1278 相离的圆
51Nod 1278 相离的圆 Link: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1278 1278 相离的圆 基 ...
- 【51Nod 1501】【算法马拉松 19D】石头剪刀布威力加强版
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1501 dp求出环状不连续的前缀和,剩下东西都可以算出来,比较繁琐. 时间 ...
- 【51Nod 1622】【算法马拉松 19C】集合对
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1622 简单题..直接暴力快速幂 #include<cstdio&g ...
- 【51Nod 1616】【算法马拉松 19B】最小集合
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1616 这道题主要是查询一个数是不是原有集合的一个子集的所有数的gcd. ...
- 【51Nod 1674】【算法马拉松 19A】区间的价值 V2
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1674 对区间分治,统计\([l,r]\)中经过mid的区间的答案. 我的 ...
- poj 1266 Cover an Arc.
http://poj.org/problem?id=1266 Cover an Arc. Time Limit: 1000MS Memory Limit: 10000K Total Submiss ...
随机推荐
- scp sparkuser@spark02:/home/sparkuser/.ssh
文件计算机传送 命令格式:{scp} {计算机用户}@{计算机网络名称}:{目标计算机路径} scp sparkuser@spark02:/home/sparkuser/.ssh
- 【2014腾讯实习招聘-面试-移动client开发】
版权声明:本文为博主原创文章,欢迎转载,转载请注明出处. https://blog.csdn.net/kana007/article/details/24375423 个人学习整理.如 ...
- android指纹
Android 6.0+指纹识别心得 Android 6.0+Fingerprint心得 数据来源:https://blog.csdn.net/lhj1076880929/article/detail ...
- Java-idea-eclipse-快捷键【mac,win】
Mac键盘符号和修饰键说明 ⌘ Command ⇧ Shift ⌥ Option ⌃ Control ↩︎ Return/Enter ⌫ Delete ⌦ 向前删除键(Fn+Delete) ↑ 上箭头 ...
- 关hashMap跟hashTable的区别
1.HashMap和Hashtable都实现了Map接口 2.HashMap是非synchronized,而Hashtable是synchronized 3.HashTable使用Enumeratio ...
- 用lua扩展你的Nginx(整理)
首先得声明.这不是我的原创,是在网上搜索到的一篇文章,原著是谁也搞不清楚了.按风格应该是属于章亦春的文章. 整理花了不少时间,所以就暂写成原创吧. 一. 概述 Nginx是一个高性能.支持高并发的,轻 ...
- Tomcat修改端口和编码配置
1.打开Tomcat中server.xml文件,找到原本的8080,修改成没被占用的端口: 2.在这个标签里增加 URIEncoding="utf-8",修改请求的编码.
- weka数据挖掘拾遗(二)---- 特征选择(IG、chi-square)
一.说明 IG是information gain 的缩写,中文名称是信息增益,是选择特征的一个很有效的方法(特别是在使用svm分类时).这里不做详细介绍,有兴趣的可以googling一下. chi-s ...
- [LeetCode] 172. Factorial Trailing Zeroes_Easy tag: Math
Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...
- xgb, lgb, Keras, LR(二分类、多分类代码)
preprocess # 通用的预处理框架 import pandas as pd import numpy as np import scipy as sp # 文件读取 def read_csv_ ...