HDU Wolf and Rabbit

简介:

Wolf and Rabbit

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 335 Accepted Submission(s): 214
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

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int t,m,n;
    cin>>t;
    while(t--)
    {
        cin>>m>>n;
        while(n>m?(n=n%m):(m=m%n));
        if(n+m==1)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}











本文转自NewPanderKing51CTO博客,原文链接:http://www.cnblogs.com/newpanderking/archive/2011/07/29/2120985.html ,如需转载请自行联系原作者


相关文章
|
弹性计算 运维 监控
GPU实例使用--vGPU驱动自动安装和升级
为了适配最新的渲染软件,以及驱动稳定性的提升,vGPU实例的驱动需要定期进行升级,因为使用vgpu的客户多数为渲染和云游戏等业务场景,对vGPU驱动的快速升级和批量自动化要求比较高。
GPU实例使用--vGPU驱动自动安装和升级
|
Web App开发 存储 监控
CentOS7.3下部署Rsyslog+LogAnalyzer+MySQL中央日志服务器
一、简介 1、LogAnalyzer 是一款syslog日志和其他网络事件数据的Web前端。它提供了对日志的简单浏览、搜索、基本分析和一些图表报告的功能。数据可以从数据库或一般的syslog文本文件中获取,所以LogAnalyzer不需要改变现有的记录架构。
2118 0
|
8月前
|
人工智能 运维 关系型数据库
|
Perl
QPS的计算
QPS = req/sec = 请求数/秒   Q:如何根据日志查看一个服务的qps   A: 一般access.log是记录请求的日志,tail  -f XXX.access.log ,可发现格式如下:     前面是请求的时间,后面有接请求的方法名字,那么我们要统计getCart的qps cat osp-cart.
6688 0
|
Java 应用服务中间件 API
从0到1学会Jetty内存马注入
最近在学习geoserver的CVE-2024-36401注入内存马的时候,发现需要注入jetty类型的内存马,这是一个不同于tomcat的轻量级web容器。具体来说,Jetty 是一个开源的servlet容器,它为基于Java的web容器,例如JSP和servlet提供运行环境。Jetty是使用Java语言编写的,它的API以一组JAR包的形式发布。开发人员可以将Jetty容器实例化成一个对象,可以迅速为一些独立运行(stand-alone)的Java应用提供网络和web连接。
|
缓存 数据可视化 算法
倾斜单体化模型技术实现
倾斜单体化模型技术实现
203 1
|
SQL 存储 分布式计算
【Hive】Hive优化有哪些?
【4月更文挑战第16天】【Hive】Hive优化有哪些?
|
存储 Prometheus 运维
(一)ACK prometheus-operator 之架构梳理
本文以troubleshooting的思维为切入点,深入梳理prometheus-operator架构原理,技术上跟阿里云arms_prometheus是相通的,便于在问题场景中快速定位。
2094 1
(一)ACK prometheus-operator 之架构梳理
|
存储 缓存 运维
【云原生】软件架构的演进以及各个架构的优缺点
软件架构是指在设计和构建软件系统时,对系统的组织结构、组件、模块、接口以及它们之间的关系和行为进行规划和定义的过程。它描述了软件系统的整体结构和组成部分之间的关系,以及系统的行为和功能。