1 条题解

  • 0
    @ 2026-3-5 17:47:42
    从大到小枚举区间长度从大到小枚举区间长度 最坏情况枚举到x,y为质数,时间可以接受最坏情况枚举到x,y为质数,时间可以接受
    #include<bits/stdc++.h>
    using namespace std;
    #define int long long
    int l,r;
    signed main(){
    	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    	cin>>l>>r;
    	for(int i=r-l;;i--){
    		for(int j=l;j+i<=r;j++){
    			if(__gcd(j,j+i)==1){
    				cout<<i<<'\n';
    				return 0;
    			}
    		}
    	}
    	
    	return 0;
    }
    
    • 1

    信息

    ID
    2473
    时间
    2000ms
    内存
    1024MiB
    难度
    10
    标签
    递交数
    3
    已通过
    2
    上传者