首页 > 其他分享 >HDU1222 Wolf and Rabbit

HDU1222 Wolf and Rabbit

时间:2022-10-18 17:03:42浏览次数:44  
标签:get int into holes signed HDU1222 Wolf Rabbit YES


A - Wolf and Rabbit

Wolf and Rabbit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9786    Accepted Submission(s): 4976


Problem Description

There is a hill with n holes around. The holes are signed from 0 to n-1.


A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into is the one signed with 0. Then he will get into the hole every m holes. For example, m=2 and n=6, the wolf will get into the holes which are signed 0,2,4,0. If the rabbit hides in the hole which signed 1,3 or 5, she will survive. So we call these holes the safe holes.

Input

The input starts with a positive integer P which indicates the number of test cases. Then on the following P lines,each line consists 2 positive integer m and n(0<m,n<2147483648).

Output

For each input m n, if safe holes exist, you should output "YES", else output "NO" in a single line.

Sample Input

2 1 2 2 2

Sample Output

NO YES

/*
题意大概为:
狼捉兔子,兔子躲在n个洞中一个
这n个洞围成一个圈
狼会从第0号洞开始,搜索隔m的洞,一直搜索下去,
问是否存在洞另狼永远搜索不到
这样兔子就重获新生。

思路就是求输入的两个数是否互质即最大公约数是否为1.
*/

#include<stdio.h>
int gcd(int a,int b)
{
return !b?a:gcd(b,a%b);
}
int main()
{
int t,a,b;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&a,&b);
if(gcd(a,b)==1) printf("NO\n");
else printf("YES\n");

}
return 0;
}


标签:get,int,into,holes,signed,HDU1222,Wolf,Rabbit,YES
From: https://blog.51cto.com/u_15834888/5767610

相关文章

  • 04 RabbitMQ 3.8 Feature Focus - Single Active Consumer
    标题:RabbitMQ3.8FeatureFocus-SingleActiveConsumer原文:https://www.cloudamqp.com/blog/rabbitmq-3-8-feature-focus-single-active-consumer.html时间:2019-04-2......
  • 9. RabbitMQ系列之消息发布确认
    PublisherConfirms发布确认是用于实现可靠发布的RabbitMQ扩展。我们将使用发布确认来确保已发布的消息已安全到达代理。我们将介绍几种使用publisher确认的策略,并解释其......
  • 2.RabbitMQ系列之生产者
    1.新建队列2.新增POM.xml配置文件<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId......
  • 1.RabbitMQ系列之服务启动
    1.docker方式启动MQ#latestRabbitMQ3.10dockerrun-it--rm--namerabbitmq-p5672:5672-p15672:15672rabbitmq:3.10-management2.登录uihttp://127.0.0.1......
  • php扩展 rabbitmq
    <?php//建立TCP连接对象$connection=newAMQPConnection(['host'=>'127.0.0.1','port'=>'5672','vhost'=>'/','login'=>'guest','......
  • RabbitMQ高可用--镜像队列的原理
    简介说明    本文介绍RabbitMQ的镜像队列的原理。镜像队列可以保证RabbitMQ的高可用,防止消息丢失。什么是镜像队列        镜像队列(MirrorQueue):将队列复......
  • 微服务项目:尚融宝(终)(核心业务流程:整合Rabbit MQ发送短信)
    认清现实,放弃幻想,准备斗争一、MQ服务器设置1、访问MQ控制台​​http://你自己虚拟机的位置:15672http://192.168.100.103:15672​​2、创建用户创建用户srbuser,配置管理员......
  • RabbitMQ基本概念
    视频参考:https://www.bilibili.com/video/BV1Et411Y7tQ?p=85&vd_source=c85b4a015a69e82ad4f202bd9b87697f博客参考:https://blog.csdn.net/xiangjunyes/article/details/1......
  • W10 启动 RabbitMQ 教程
       启动服务   1.进入rabbitmq的安装sbin目录下cmd进入命令窗口          2.cmd输入命令rabbitmq-server.bat,如图启动成功    ......
  • RabbitMQ如何保证消息的可靠性
    如何确保RabbitMQ消息的可靠性对于生产者,开启生产者确认机制,确保生产者的消息能到达队队列对于mq,开启持久化功能,确保消息未消费前在队列中不会丢失对于消费者,开......