题目 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");
        }
    }
}
相关推荐
iCxhust12 分钟前
51单片机电力载波应用开发(七)广播通讯
c语言·开发语言·单片机·嵌入式硬件·51单片机
殷色玫瑰1 小时前
C++ STL:stack、queue、priority_queue 与容器适配器详解
java·开发语言·数据结构·c++·算法·visualstudio
IT方大同1 小时前
java输入输出+方法
java·开发语言·python
滕州市燕猫虎计算机科技工作室个体工商户1 小时前
《Rust程序设计》学习笔记一
开发语言·rust·学习笔记·rust程序设计
Yyyyyy~1 小时前
【Java】String
java
Wang's Blog1 小时前
Java框架 SpringCloud 快速入门: 服务拆分之服务远程调用
java·开发语言·spring cloud
努力努力再努力wz1 小时前
【CUDA入门系列】CUDA编程实战:设备选择、显存管理、Kernel、Stream 与 Event 全流程梳理
开发语言·c++
Wang's Blog1 小时前
Java框架 SpringCloud 快速入门: 路由断言工厂
java·spring·spring cloud
ym hyd 1112 小时前
门诊挂号系统源码 Java+SpringBoot+Vue3 前后分离
java·vue.js·spring boot·毕设
杨丰玮4182 小时前
C语言核心语法
java·c语言·开发语言·学习方法