B.Different Rules(思维+找规律)

这篇博客主要讨论了Codeforces网站上的1313B问题,作者分析了如何针对最大值和最小值的情况来构造解题策略。博客内容涉及动态规划和数学思维,通过具体的例子展示了如何找到规律并进行证明。代码实现部分展示了C++解决方案,用于计算在给定限制下可能的范围。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://codeforces.com/problemset/problem/1313/B


思路:

分别对最大最小的情况分开构造,只能找找规律这样子。

具体的证明在cf上..

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n,x,y;cin>>n>>x>>y;
    cout<<max(LL(1),min(x+y-n+1,n))<<" ";
    cout<<min(x+y-1,n)<<"\n";
  }
return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值