题目链接:Here

    题意:

    给出正整数 AtCoder ABC 165 D - Floor Function - 图1#card=math&code=A%2CB%2CN%20%281%5Cle%20A%5Cle%201e6%2C1%5Cle%20B%2CN%5Cle1e12%29) ,对于 AtCoder ABC 165 D - Floor Function - 图2 求出

    • AtCoder ABC 165 D - Floor Function - 图3

    的最大值


    AtCoder ABC 165 D - Floor Function - 图4


    全搜索的话 AtCoder ABC 165 D - Floor Function - 图5#card=math&code=%5Cmathcal%7BO%7D%28n%29) 的时间复杂度是肯定不行的,直接看过去公式应该能够化简,

    如果不是 AtCoder ABC 165 D - Floor Function - 图6 (向下取整) ,而是实数运算的话, AtCoder ABC 165 D - Floor Function - 图7 就恒成立了

    大概如上思考的话,总觉得为了使 AtCoder ABC 165 D - Floor Function - 图8 这个值更大,原公式后面部分的 AtCoder ABC 165 D - Floor Function - 图9 应该尽可能的靠近向上取整得到的整数,即尽可能得到 AtCoder ABC 165 D - Floor Function - 图10#card=math&code=%28.999999%29) 这样的答案,此时差值就变大起来了

    实际模拟一下

    样例一:AtCoder ABC 165 D - Floor Function - 图11

    AtCoder ABC 165 D - Floor Function - 图12 AtCoder ABC 165 D - Floor Function - 图13 AtCoder ABC 165 D - Floor Function - 图14 差值
    0 0 0 0
    1 0 0 0
    2 1 0 1
    3 2 0 2
    4 2 0 2
    5 3 0 3
    6 4 0 4
    7 5 5 0
    8 5 5 0
    9 6 5 1
    10 7 5 2
    11 7 5 2
    12 8 5 3
    13 9 5 4

    而且要注意的是:

    • AtCoder ABC 165 D - Floor Function - 图15 是周期的增加,AtCoder ABC 165 D - Floor Function - 图16%2CA(%3D5)#card=math&code=B%28%3D7%29%2CA%28%3D5%29)

    同理:AtCoder ABC 165 D - Floor Function - 图17 也是一样的

    AtCoder ABC 165 D - Floor Function - 图18%20%3D%20%5Cleft%5Clfloor%5Cfrac%7BA%20x%7D%7BB%7D%5Cright%5Crfloor-A%20%5Ctimes%5Cleft%5Clfloor%5Cfrac%7Bx%7D%7BB%7D%5Cright%5Crfloor#card=math&code=f%28x%29%20%3D%20%5Cleft%5Clfloor%5Cfrac%7BA%20x%7D%7BB%7D%5Cright%5Crfloor-A%20%5Ctimes%5Cleft%5Clfloor%5Cfrac%7Bx%7D%7BB%7D%5Cright%5Crfloor) 的取值对于 AtCoder ABC 165 D - Floor Function - 图19 来说是周期性的,所以 AtCoder ABC 165 D - Floor Function - 图20 的取值

    • AtCoder ABC 165 D - Floor Function - 图21

    考虑这么多即可


    AtCoder ABC 165 D - Floor Function - 图22 的范围中

    • AtCoder ABC 165 D - Floor Function - 图23 单调递增
    • AtCoder ABC 165 D - Floor Function - 图24 保持不变
    • 那么 AtCoder ABC 165 D - Floor Function - 图25#card=math&code=f%28x%29) 单调性也就是同 AtCoder ABC 165 D - Floor Function - 图26 一样单调递增了

    换句话说,只要满足

    • AtCoder ABC 165 D - Floor Function - 图27
    • AtCoder ABC 165 D - Floor Function - 图28

    的话符合条件的最大 AtCoder ABC 165 D - Floor Function - 图29 应该是 AtCoder ABC 165 D - Floor Function - 图30#card=math&code=x%3D%5Cmin%28N%2CB-1%29)

    那么最后答案输出 $ \frac AB\times \min(N,B-1)$ 即可

    时间复杂度由全搜索的 AtCoder ABC 165 D - Floor Function - 图31%20%5Cto%20%5Cmathcal%7BO%7D(1)#card=math&code=%5Cmathcal%7BO%7D%28n%29%20%5Cto%20%5Cmathcal%7BO%7D%281%29)

    1. ll a, b, n;
    2. int main() {
    3. cin.tie(nullptr)->sync_with_stdio(false);
    4. cin >> a >> b >> n;
    5. cout << a * min(n, b - 1) / b;
    6. }