题目 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");
        }
    }
}
相关推荐
码出财富7 小时前
SpringBoot 内置的 20 个高效工具类
java·spring boot·spring cloud·java-ee
沐知全栈开发7 小时前
Perl 数据库连接
开发语言
我是小疯子667 小时前
Python变量赋值陷阱:浅拷贝VS深拷贝
java·服务器·数据库
森叶7 小时前
Java 比 Python 高性能的原因:重点在高并发方面
java·开发语言·python
二哈喇子!7 小时前
Eclipse中导入外部jar包
java·eclipse·jar
微露清风7 小时前
系统性学习C++-第二十二讲-C++11
java·c++·学习
qq_316837758 小时前
uni.chooseMedia 读取base64 或 二进制
开发语言·前端·javascript
方圆工作室8 小时前
【C语言图形学】用*号绘制完美圆的三种算法详解与实现【AI】
c语言·开发语言·算法
小二·8 小时前
Python Web 开发进阶实战:混沌工程初探 —— 主动注入故障,构建高韧性系统
开发语言·前端·python
Lkygo8 小时前
LlamaIndex使用指南
linux·开发语言·python·llama