题目 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");
        }
    }
}
相关推荐
玄同7655 分钟前
Python 装饰器:LLM API 的安全与可观测性增强
开发语言·人工智能·python·安全·自然语言处理·numpy·装饰器
为什么要做囚徒11 分钟前
多线程基础系列-线程死锁
java·多线程
superman超哥12 分钟前
Rust 过程宏开发入门:编译期元编程的深度实践
开发语言·后端·rust·元编程·rust过程宏·编译期
bluetata16 分钟前
在 Spring Boot 中使用 Amazon Textract 从图像中提取文本
java·spring boot·后端
GesLuck17 分钟前
伺服电机(200 smart & )调试文档
开发语言·驱动开发·硬件工程
黎雁·泠崖25 分钟前
Java底层探秘入门:从源码到字节码!方法调用的中间形态全解析
java·开发语言
千里马-horse26 分钟前
TypedArrayOf
开发语言·javascript·c++·node.js·napi
we1less31 分钟前
[audio] AudioTrack (六) 共享内存使用分析
java·开发语言
CYTElena32 分钟前
关于JAVA异常的笔记
java·开发语言·笔记·语言基础
YIN_尹33 分钟前
【C++11】lambda表达式(匿名函数)
java·c++·windows