题目 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");
        }
    }
}
相关推荐
云深麋鹿3 分钟前
C++ | 容器vector
开发语言·c++·容器
格林威3 分钟前
工业相机图像高速存储(C#版):直接IO存储方法,附海康相机C#实战代码!
开发语言·人工智能·数码相机·c#·工业相机·海康相机·堡盟相机
w1225h4 分钟前
【SpringBoot】Spring Boot 项目的打包配置
java·spring boot·后端
李少兄4 分钟前
解析 IntelliJ IDEA “Immutable object is modified”警告
java·ide·intellij-idea
下雨打伞干嘛5 分钟前
手写Promise
开发语言·前端·javascript
客卿1235 分钟前
二叉树的层序遍历--思路===bfs的应用,以及java中队列的方法实操
java·算法·宽度优先
Ronin3056 分钟前
【Qt常用控件】输入类控件
开发语言·qt·常用控件·输入类控件
健康平安的活着6 分钟前
java中事务@Transaction的正确使用和触发回滚机制【经典】
java·开发语言
Han.miracle8 分钟前
IntelliJ IDEA 高效开发实用技巧
java·ide·intellij-idea
全栈软件开发8 分钟前
中小汽修门店汽修单管理系统PHP源码,数字化管理维修订单与客户信息
开发语言·php