数据给出 R−L≤109R−L \le 10^9R−L≤109 所以这个 O(R−L)O(R-L)O(R−L) 的代码应该是能过的吧。
#include<bits/stdc++.h> using namespace std; int n,l,r; int maxx=0; int main() { ios::sync_with_stdio(0); cin.tie(0); cin>>n>>l>>r; for(int i=l;i<=r;i++) { maxx=max(maxx,i%n); } cout<<maxx; return 0; }