题目 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");
        }
    }
}
相关推荐
liangsheng_g10 分钟前
微服务本地开发零配置隔离方案
java·微服务·架构
知识分享小能手12 分钟前
概理论与数理统计学习教程,从入门到精通,在数理统计中应用R软件(22)
开发语言·学习·r语言
不服老的小黑哥14 分钟前
六、集合处理(collections.md)
java
乐观勇敢坚强的老彭16 分钟前
C++信奥GESP四级的常见题型和解题模板速查表
开发语言·c++
denggun1234523 分钟前
信号量(DispatchSemaphore vs AsyncSemaphore)、swift协作式线程池 and python信号量
开发语言·python·swift
lisw0525 分钟前
计算与科学哲学(Philosophy of Computing and Science)
java·开发语言·人工智能
凤山老林26 分钟前
Spring Boot 集成 ShardingSphere-Encrypt 实现字段级实时脱敏
java·spring boot·后端·数据脱敏
vipxieliang26 分钟前
ValidX v1.2.0 更新日志
java·后端
叫我Paul就好1 小时前
Spring 为何没有在 Java之外的地方存在?
java·后端·spring
深念Y1 小时前
为什么选 Go:直观、可维护、AI 友好
linux·开发语言·人工智能·golang·agent·harness