题目 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");
        }
    }
}
相关推荐
秋名RG5 分钟前
2026/5/27 生产事故复盘与整改方案
java
传奇开心果编程19 分钟前
【Rust入门知识点学与练】第10课:Option 和 Result(错误处理入门)
开发语言·学习·rust
leonkay34 分钟前
C# 锁机制——【2】深入原理
开发语言·后端·spring·c#·个人开发
血小板要健康44 分钟前
链表 阶段算法总结
java·数据结构·笔记·算法·leetcode·链表
坐吃山猪44 分钟前
【多线程】CompletableFuture使用
java·开发语言·多线程
CHPCWWHSU1 小时前
DeepSeek-Harness-Qt将浏览器端Agent装入桌面应用
开发语言·qt
m0_587383001 小时前
点餐预约核销系统的架构脉络
java·架构·系统架构·需求分析
前端 贾公子1 小时前
第10章:RAG(2)
开发语言·python
代码方舟2 小时前
O2O二手车交易平台B端车商管理后台:基于天远车信盟出险构建自动化车况评估网关
java·运维·人工智能·自动化
爱学堂IT分享2 小时前
图灵Java互联网架构师六期
java·开发语言