题目 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");
        }
    }
}
相关推荐
不会聊天真君6476 分钟前
基础语法·中(golang笔记第二期)
开发语言·笔记·golang
m0_569881477 分钟前
C++中的适配器模式变体
开发语言·c++·算法
第二层皮-合肥13 分钟前
基于C#的工业测试控制软件-总体框架
开发语言·c#
lsx20240617 分钟前
ionic 单选框操作详解
开发语言
飞Link28 分钟前
Python Pydantic V2 核心原理解析与企业级实战指南
开发语言·python
比昨天多敲两行1 小时前
C++ 多态
开发语言·c++
、BeYourself1 小时前
Scala 字面量
开发语言·后端·scala
Amumu121381 小时前
JS:ES6~ES11基础语法(二)
开发语言·前端·javascript
Amumu121381 小时前
Js:ES6~ES11基础语法(一)
开发语言·前端·javascript