题目 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");
        }
    }
}
相关推荐
wuqingshun3141594 小时前
什么是责任链模式,一般用在什么场景?
java·责任链模式
江畔柳前堤4 小时前
GO01-Go 语言与主流编程语言深度对比
开发语言·人工智能·后端·微服务·云原生·golang·go
:-)4 小时前
算法-归并排序
java·开发语言·数据结构·算法·排序算法
wuqingshun3141595 小时前
说一下消息队列的模型有哪些?
java
GIS阵地5 小时前
QgsRasterDataProvider 完整详解(QGIS 3.40.13 C++)
开发语言·c++·qt·开源软件·qgis
fīɡЙtīиɡ ℡6 小时前
布隆过滤器
java
yaoxin5211236 小时前
462. Java 反射 - 获取声明类与封闭类
java·开发语言·python
阿里嘎多学长6 小时前
2026-07-14 GitHub 热点项目精选
开发语言·程序员·github·代码托管
charlie1145141917 小时前
Cinux: 为大内核铺路
开发语言·c++·操作系统·现代c++
2501_914245937 小时前
C语言设计模式详解:从理论到实践的完整指南
c语言·开发语言·设计模式