题目 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");
        }
    }
}
相关推荐
郝学胜-神的一滴1 小时前
Effective Modern C++ 条款38:线程句柄析构行为与Vibe Coding优化指南
开发语言·数据结构·c++·程序人生·多线程·并发
锅包一切1 小时前
【蓝桥杯JavaScript基础入门】二、JavaScript关键特性
开发语言·前端·javascript·学习·蓝桥杯
那我掉的头发算什么2 小时前
【图书管理系统】基于Spring全家桶的图书管理系统(下)
java·数据库·spring boot·后端·spring·mybatis
张3蜂2 小时前
Python 中的 Conda 详解:它到底解决了什么问题?
开发语言·python·conda
大闲在人10 小时前
C、C++区别还是蛮大的
c语言·开发语言·c++
小灵不想卷10 小时前
LangChain4j Low 和 Hight-level API
java·langchain4j
Cosmoshhhyyy11 小时前
《Effective Java》解读第39条:注解优先于命名模式
java·开发语言
亓才孓11 小时前
[SpringIOC]NoSuchBeanDefinitionException
java·spring
追随者永远是胜利者11 小时前
(LeetCode-Hot100)20. 有效的括号
java·算法·leetcode·职场和发展·go