暴力穷举
#include <iostream>
using namespace std;
int n, l, r;
int main(){
cin >> n >> l >> r;
int ans = -1;
for(int i = l; i <= r; i++){
ans = max(ans, i % n);
}
cout << ans;
return 0;
}
数学方法
#include <iostream>
using namespace std;
int n, l, r;
int main(){
cin >> n >> l >> r;
if(l/n == r/n) cout << max(l%n, r%n);
else cout << n-1;
return 0;
}