版权声明:反正也没有人会转,下一个 https://blog.csdn.net/drtlstf/article/details/82729114
Description
在二维坐标系里,有N个金币,编号0至N-1。初始时,第i个金币的坐标是(Xi,Yi)。所有的金币每秒向下垂直下降一个单位高度,例如有个金币当前坐标是(xf, yf),那么t秒后金币所在的位置就是(xf, yf-t)。初始时,FJ在(0,0)坐标处,FJ每秒只能向左移动一个单位距离或者向右移动一个单位距离,当然FJ也可以不移动。如果在某个时刻某个金币和FJ所在的位置重合,那么FJ就能接住这个金币。FJ能否把所有的金币都接住?如果行输出Abletocatch,否则输出Notabletocatch。
Input
多组测试数据。
第一行,一个整数G,表示有G组测试数据。1 <= G <= 5。
每组测试数据格式如下:
第一行,一个整数N。 1 <= N <= 50。
接下来有N行,第i行两个整数表示Xi、Yi。
-1000<=Xi<=1000。0<=Yi<=1000。
Output
共G行,每行输出Abletocatch或Notabletocatch。
Sample Input
5
3
-1 1
1 3
0 4
1
-3 2
3
-1 1
1 2
0 4
3
0 9
-1 1
1 3
8
70 141
-108 299
52 402
-70 280
84 28
-29 363
66 427
-33 232
Sample Output
Abletocatch
Notabletocatch
Notabletocatch
Abletocatch
Notabletocatch
\ /
\ /
\ /
\ /
\ /
\ 能接到的范围 / 不能
\ / 接到
\ / 的范围
\ /
不能 \ /
接到 \ /
的范围 \ /
\ /
\ /
\ /
\ /
\ /
\ /
\/
你在这里
以上推理
#include <iostream>
#include <cmath>
#include <algorithm>
#define SIZE 55
using namespace std;
struct node
{
int x, y;
};
node a[SIZE];
bool comp(node a, node b)
{
return a.y < b.y;
}
int main(int argc, char** argv)
{
int t, n, i;
bool flag;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
for (i = 1; i <= n; ++i)
{
scanf("%d%d", &a[i].x, &a[i].y);
}
flag = true;
sort(a + 1, a + n + 1, comp);
for (i = 1; i <= n; ++i)
{
if (abs(a[i].y - a[i-1].y) < abs(a[i].x - a[i-1].x)) // 判定是否在能接到的范围
{
flag = false;
break;
}
}
printf("%sbletocatch\n", ((flag) ? "A" : "Nota"));
}
return 0;
}