本文共 799 字,大约阅读时间需要 2 分钟。
给你n和m,你要按n次按钮,接下来m行,每行a和b,代表上a层,下b层,但不能钻到地下去。
假设上x层,则下(n-x)层,所以有a*x-b*(n-x)>0,==>(a+b)*x-b*n>0,==>x=(b*n+a+b)/(a+b);
//// main.cpp// 160929//// Created by 刘哲 on 17/4/6.// Copyright © 2016年 my_code. All rights reserved.////#include #include #include #include #include #include #include #include