输入3个数:n,k,c (1 <= n <= 10^9, 1 <= c <= k <= 10^9)。
输出最坏情况下所需的最少询问次数。
4 2 2
4
#include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <string> #include <functional> #include <cmath> #include <set> #include <queue> #include <algorithm> #include <vector> #include <map> #include <stack> using namespace std; #define esp 1e-8 const double PI = acos(-1.0); const double e = 2.718281828459; const int inf = 2147483647; const long long mod = 1000000007; //freopen("in.txt","r",stdin); //输入重定向,输入数据将从in.txt文件中读取 //freopen("out.txt","w",stdout); //输出重定向,输出数据将保存在out.txt文件中cin int main() { int n, k, c, i, j; while (~scanf("%d%d%d", &n, &k, &c)) { int x = k / n; int y = n - k % n; if (x * n >= c || k % n == 0) printf("%d\n", c); else { int z = k / (x + 1); z = n - z + c; //cout << z << endl; printf("%d\n", min(z, c + y)); } } }