当前位置:网站首页>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
边栏推荐
- What is the most suitable book for programmers to engage in open source?
- Threedposetracker project resolution
- Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
- Live video source code, realize local storage of search history
- FFT learning notes (I think it is detailed)
- c#网页打开winform exe
- Nmap: network detection tool and security / port scanner
- BiShe - College Student Association Management System Based on SSM
- Leetcode daily question solution: 1189 Maximum number of "balloons"
- Format code_ What does formatting code mean
猜你喜欢

Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...

Introduction to robotics I. spatial transformation (1) posture, transformation

ADS-NPU芯片架构设计的五大挑战

有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀

Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks

1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once

Huawei Hrbrid interface and VLAN division based on IP

【已解决】如何生成漂亮的静态文档说明页

leetcode刷题_验证回文字符串 Ⅱ

Convert binary search tree into cumulative tree (reverse middle order traversal)
随机推荐
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
Three methods of script about login and cookies
Folio.ink 免费、快速、易用的图片分享工具
Yii console method call, Yii console scheduled task
ClickOnce 不支持请求执行级别“requireAdministrator”
The inconsistency between the versions of dynamic library and static library will lead to bugs
A Cooperative Approach to Particle Swarm Optimization
GNSS terminology
基於DVWA的文件上傳漏洞測試
What is the most suitable book for programmers to engage in open source?
Vulhub vulnerability recurrence 74_ Wordpress
Xunrui CMS plug-in automatically collects fake original free plug-ins
Docker compose configures MySQL and realizes remote connection
Convert binary search tree into cumulative tree (reverse middle order traversal)
【第30天】给定一个整数 n ,求它的因数之和
WordPress collection plug-in automatically collects fake original free plug-ins
记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
A picture to understand! Why did the school teach you coding but still not
Unity | 实现面部驱动的两种方式
什么是弱引用?es6中有哪些弱引用数据类型?js中的弱引用是什么?