当前位置:网站首页>Luo Gu P1170 Bugs Bunny and Hunter
Luo Gu P1170 Bugs Bunny and Hunter
2022-07-06 01:25:00 【zjsru_ Beginner】
Title Description
Bugs Bunny hid in the orchard next to the forest . The orchard has M×N tree , Form a M That's ok N Columns of the matrix , The distance between two horizontally or vertically adjacent trees is 1. Bugs Bunny is under a fruit tree .
The hunter walked into the orchard with his shotgun on his back , He climbed up a fruit tree , Ready to kill bugs bunny .
If there are no other fruit trees between the hunter and Bugs Bunny , The hunter can see bugs bunny .
Now we know the location of the hunter and bugs bunny , Write a program to determine whether the location of the rabbit is safe .
Input format
First act nn, Express nn Group data , The first line of each set of data is two positive integers ax and ay, Indicates the location of the Hunter , The second line is two positive integers bx and by, Indicates the location of bugs bunny .
Output format
share n That's ok , Every act yes
or no
Indicates whether Bugs Bunny's position is safe .
I/o sample
Input #1 Copy
1 1 1 1 2
Output #1 Copy
no
explain / Tips
1≤n≤1051≤ax,ay,bx,by≤108.
Their thinking
This question is very misleading at the beginning , When I just finished reading the topic , I think most people should think that there is only one circle around the hunter 8 One point is dangerous . In fact, this is incomplete . Suppose the hunter is the origin except for the appeal 8 There are many other points besides, for example (2,1)(1,4) Wait, but these points also have rules to follow . Hunters want to kill rabbits. Rabbits only happen when the absolute value of the coordinate difference of their stations is mutual prime .
#include<bits/stdc++.h>
using namespace std;
int n, rx, ry, lrx, lry;
int gcd(int x, int y)
{
if (y == 0) return x;
else return (gcd(y, x % y));
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> lrx >> lry >> rx >> ry;
if (gcd(abs(lrx - rx), abs(lry - ry)) == 1) cout << "no\n";
else cout << "yes\n";
}
return 0;
}
Computer 202 yjq
边栏推荐
- MySQL learning notes 2
- 伦敦银走势中的假突破
- ClickOnce 不支持请求执行级别“requireAdministrator”
- SPIR-V初窥
- 视频直播源码,实现本地存储搜索历史记录
- [understanding of opportunity-39]: Guiguzi - Chapter 5 flying clamp - warning 2: there are six types of praise. Be careful to enjoy praise as fish enjoy bait.
- Dede collection plug-in free collection release push plug-in
- Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
- Convert binary search tree into cumulative tree (reverse middle order traversal)
- SSH login is stuck and disconnected
猜你喜欢
Dedecms plug-in free SEO plug-in summary
File upload vulnerability test based on DVWA
How to see the K-line chart of gold price trend?
DOM introduction
Huawei Hrbrid interface and VLAN division based on IP
c#网页打开winform exe
Daily practice - February 13, 2022
伦敦银走势中的假突破
[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。
037 PHP login, registration, message, personal Center Design
随机推荐
Ubantu check cudnn and CUDA versions
[Arduino syntax - structure]
记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
Nmap: network detection tool and security / port scanner
Electrical data | IEEE118 (including wind and solar energy)
Finding the nearest common ancestor of binary tree by recursion
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
Unity VR solves the problem that the handle ray keeps flashing after touching the button of the UI
【全网最全】 |MySQL EXPLAIN 完全解读
Vulhub vulnerability recurrence 75_ XStream
internship:项目代码所涉及陌生注解及其作用
[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。
What is the most suitable book for programmers to engage in open source?
Format code_ What does formatting code mean
Recursive method to realize the insertion operation in binary search tree
2020.2.13
MATLB | real time opportunity constrained decision making and its application in power system
SSH login is stuck and disconnected
Folio.ink 免费、快速、易用的图片分享工具
基于DVWA的文件上传漏洞测试