题目 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");
        }
    }
}
相关推荐
tqs_1234517 小时前
倒排索引数据结构
java·前端·算法
2501_9445264217 小时前
Flutter for OpenHarmony 万能游戏库App实战 - 抽牌游戏实现
android·开发语言·python·flutter·游戏
a程序小傲17 小时前
听说前端又死了?
开发语言·前端·mysql·算法·postgresql·深度优先
饱饱要坚持可持续发展观17 小时前
SpringBoot 集成 Liquibase
java·spring boot·后端
学Linux的语莫17 小时前
python项目打包为镜像
java·python·spring
Ashley_Amanda17 小时前
Python 进阶:从熟练到精通的核心技能体系
开发语言·python
你怎么知道我是队长17 小时前
C语言---命令行参数
c语言·开发语言
秋刀鱼程序编程17 小时前
Java编程基础入门(四)---选择循环语句
java·开发语言·算法
一条咸鱼_SaltyFish17 小时前
WebFlux vs MVC:Gateway集成若依框架的技术选型之争
java·开发语言·微服务·gateway·mvc·开源软件·webflux
独自归家的兔17 小时前
Java反射之根:Class类生成机制深度剖析与最佳实践
java·开发语言