题意简述
给定正整数 ,求:
解题思路
将区间 划分为长度为 的段,在同一段内 单调递增,且最大值为 。
- 若 ,说明 位于同一段内,取 时答案为 ;
- 否则, 跨越至少一段,取 时答案为 。
参考代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,l,r;
cin>>n>>l>>r;
cout<<(l/n==r/n?r%n:n-1)<<'\n';
return 0;
}