题目 2701: 取模

题目描述:

给定 n, m ,问是否存在两个不同的数 x, y 使得 1 ≤ x < y ≤ m 且 n mod x = n mod y 。

代码:

java 复制代码
package lanqiao;

import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t -- != 0)
        {
            int n = sc.nextInt();
            int m = sc.nextInt();
            boolean tf = false;
            for(int x = 1;x <= m;x ++)
            {
                for(int y = 1;y < x;y ++){
                    if(x == y || n % x != n % y){
                        continue;
                    }
                    tf = true;
                    break;
                }
                if(tf)
                {
                    break;
                }
            }
            if(tf)
            {
                System.out.println("Yes");
                continue;
            }
            System.out.println("No");
        }
    }
}
相关推荐
轩情吖几秒前
Qt多元素控件之QTableWidget
开发语言·c++·qt·表格·控件·qtablewidget
froginwe111 分钟前
PostgreSQL 表达式详解
开发语言
让我上个超影吧2 分钟前
SpringAI会话记忆实现——基于MYSQL进行存储
java·spring boot·ai
LuminescenceJ4 分钟前
RPC通信中的Context上下文如何跨进程传递消息,gRPC为例分析
开发语言·网络·后端·网络协议·rpc·golang
IT陈图图6 分钟前
Flutter × OpenHarmony 实战:优雅构建确认对话框的组件化方案
开发语言·javascript·flutter
雨季6666 分钟前
Flutter 三端应用实战:OpenHarmony 简易文本末尾字符查看器开发指南
开发语言·javascript·flutter
Lxinccode7 分钟前
python(70) : 网页IDE
开发语言·ide·python·网页ide
zmjjdank1ng8 分钟前
理解bash和shell
linux·运维·开发语言·bash
码界奇点9 分钟前
基于Beego v2与Go语言的网站管理后台系统设计与实现
开发语言·golang·毕业设计·go语言·源代码管理·beego
潇凝子潇10 分钟前
Arthas 火焰图的使用
开发语言·python