1 solutions
-
0
模拟(90pts)
- 枚举L到R的所有糖果,得到所有可能的情况的糖果的最大值。
#include<bits/stdc++.h> using namespace std; int main() { int n,L,R; cin>>n>>L>>R; int res=0; for(int i=L;i<=R;i++) //枚举拿的糖的数目 { res=max(res,i%n); //得到糖果奖励 } cout<<res; return 0; }
数学(100pts)
- 当区间足够大的时候,得到的糖果奖励一定是上升,然后从0开始继续上升,如果L和R不是在同一段,那么一定可以得到最大值,否则R一定是最大值。
#include<bits/stdc++.h> using namespace std; int main() { int n,l,r; cin>>n>>l>>r; if(l/n!=r/n) //不在同一组 { cout<<n-1; } else //一定是一直上升的,r最大 { cout<<r%n; } return 0; }
- 1
Information
- ID
- 1071
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- # Submissions
- 6
- Accepted
- 3
- Uploaded By