题目 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");
        }
    }
}
相关推荐
jieyucx17 小时前
# Go 语言指针零基础入门详解
开发语言·后端·golang
4***175417 小时前
3.3 Python图形编程
开发语言·python·pygame
橙子圆12317 小时前
java之拦截器和适配器模式
java·开发语言
时空系17 小时前
第3篇:数据的运算——让数据动起来 Rust中文编程
开发语言·后端·rust
Shadow(⊙o⊙)17 小时前
智能指针、循环引用、锁、删除器
开发语言·c++·后端·visual studio
lifewange17 小时前
Claude Code可以安装在IDEA和Pycharm中么
java·pycharm·intellij-idea
lifewange17 小时前
OpenCode可以安装在IDEA和Pycharm中么
java·pycharm·intellij-idea
Sylvia-girl17 小时前
C++模板【上】
开发语言·c++
2zcode17 小时前
基于MATLAB多特征融合与SVM的金属表面缺陷检测系统
开发语言·支持向量机·matlab
2zcode17 小时前
基于MATLAB脑电信号的帕金森病抑郁症检测研究
开发语言·matlab·抑郁症·帕金森病