1 条题解

  • 0
    @ 2025-8-24 22:46:41

    自动搬运

    查看原文

    来自洛谷,原作者为

    avatar lailai0916
    Student & Developer

    搬运于2025-08-24 22:46:41,当前版本为作者最后更新于2023-05-07 16:39:10,作者可能在搬运后再次修改,您可在原文处查看最新版

    自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多

    以下是正文


    原题链接

    解题思路

    1. bb 变成 b+1b+1,即再造一个特殊金属 X 时,V=ab+1V=\left\lfloor\frac{a}{b+1}\right\rfloor。此时为 刚好不满足条件的情况,所以 V=ab+1+1V=\left\lfloor\frac{a}{b+1}\right\rfloor+1满足条件的最小情况
    Vmin=ab+1+1V_{min}=\left\lfloor\frac{a}{b+1}\right\rfloor+1
    1. 同理,满足条件的最大情况ab\left\lfloor\frac{a}{b}\right\rfloor
    Vmax=abV_{max}=\left\lfloor\frac{a}{b}\right\rfloor
    1. 最终取所有记录的交集,即取所有 VminV_{min}最大值VmaxV_{max}最小值

    参考代码

    #include <bits/stdc++.h>
    using namespace std;
    
    const int inf=0x3f3f3f3f;
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(nullptr);
    	int n;
    	cin>>n;
    	int mn=0,mx=inf;
    	while(n--)
    	{
    		int a,b;
    		cin>>a>>b;
    		mn=max(mn,a/(b+1)+1);
    		mx=min(mx,a/b);
    	}
    	cout<<mn<<' '<<mx<<'\n';
    	return 0;
    }
    
    • 1

    信息

    ID
    8677
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    0
    已通过
    0
    上传者