Poj1852】的更多相关文章

https://vjudge.net/problem/POJ-1852 最短时间显然是各自往靠近端点的地方走. 最长时间关键是要想到,折返和擦肩其实是一样的,可以当成两只蚂蚁换了个位子,最终求max是一样的. #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> #include<cmath> #include…
求最短时间和最长时间. 当两个蚂蚁相遇的时候,可以看做两个蚂蚁穿过,对结果没有影响.O(N)的复杂度 c++版: #include <cstdio> #define min(a, b) (a) < (b) ? (a) : (b) #define max(a, b) (a) > (b) ? (a) : (b) int main(void) { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin);…
题目求的是:所有蚂蚁用最短时间从木棍上走下来的最大值(也就是最后一个蚂蚁什么时候走下来的) 所有蚂蚁中,用时最长的情况 PS:根本不用考虑两只蚂蚁相遇又折返的情况(可以直接认为是他两互不影响的走) #include <iostream> using namespace std; int main() { int t; cin >> t; while(t--) { ; , max_t = ; cin >> len >> ants; int length; ;…
Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12431   Accepted: 5462 Description An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediat…
题目链接:http://poj.org/problem?id=1852 题意:木板长为n,    蚂蚁数量为k,    后面k个数,依次代表蚂蚁的位置,  当蚂蚁到达边界的时候会立马掉下,当两个蚂蚁相碰面的时候,两蚂蚁各种反向走.(蚂蚁走的方向不定,但秒速度为1)   求所有蚂蚁都掉下来的最早时间和最晚时间. 思路:最早时间很容易求,就不多说了. 对于最晚时间,    对于两个蚂蚁相碰面,两个蚂蚁各自反向走,在这里可以看成两个蚂蚁方向都不变,沿着相同方向继续行走,得到的效果是一样的. AC代码:…
Ants Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12782   Accepted: 5596 Description An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it imm…
题目 An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they turn back and start walking in opposite directions…
题干 An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they turn back and start walking in opposite directions…
  Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1363   Accepted: 476   Special Judge Description Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment, all N balls are f…