题目 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");
        }
    }
}
相关推荐
HerayChen3 小时前
HbuilderX 内存溢出报错
java·大数据·linux
diegoXie3 小时前
Python / R 向量顺序分割与跨步分割
开发语言·python·r语言
程序员小白条3 小时前
0经验如何找实习?
java·开发语言·数据结构·数据库·链表
liulilittle4 小时前
C++ 浮点数封装。
linux·服务器·开发语言·前端·网络·数据库·c++
小马爱打代码4 小时前
Spring AI:搭建自定义 MCP Server:获取 QQ 信息
java·人工智能·spring
郭涤生4 小时前
QT 架构笔记
java·数据库·系统架构
daidaidaiyu4 小时前
基于LangGraph开发复杂智能体学习一则
java·ai
失散134 小时前
Python——1 概述
开发语言·python
萧鼎4 小时前
Python 图像哈希库 imagehash——从原理到实践
开发语言·python·哈希算法
小小8程序员5 小时前
STL 库(C++ Standard Template Library)全面介绍
java·开发语言·c++