题目 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");
        }
    }
}
相关推荐
J2虾虾11 小时前
使用Idea当Jar包的反编译
java·intellij-idea·jar
chushiyunen11 小时前
python fastapi使用、uvicorn
开发语言·python·fastapi
成都易yisdong11 小时前
实现三北方向转换计算器(集成 WMM2025 地磁模型)
开发语言·windows·算法·c#·visual studio
白露与泡影11 小时前
2026 全新 Java 面试题汇总(含答案)
java·开发语言
likerhood11 小时前
IDEA中创建和运行java项目的常见操作
java·ide·intellij-idea
jinanwuhuaguo12 小时前
OpenClaw 2026年4月升级大系深度解读剖析:从“架构重塑”到“信任内建”的范式跃迁
android·开发语言·人工智能·架构·kotlin·openclaw
geovindu12 小时前
go: Simple Factory Pattern
开发语言·后端·设计模式·golang·简单工厂模式
计算机学姐12 小时前
基于SpringBoot的房屋交易系统
java·vue.js·spring boot·后端·spring·intellij-idea·mybatis
xixixi7777712 小时前
从5G标准到6G前沿:Polar码的技术演进与未来之路
开发语言·人工智能·5g·大模型·php·通信·polar码
CQU_JIAKE12 小时前
4.12[A]
java