题目描述:
解题思路:
本题采用二分中的二分答案。且本题check()用不到开数组,所以不需要开数组,脑海中想象一个数组就好了
题解:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m , k;
ll check(ll mid)//引入参数为ll类型
{
ll res = 0;
for(int i = 1; i <= n; i++)res += min(m, mid/i);//注意:mid只能相同数据类型的比较,ll/int为ll类型
return res;
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m >> k;
ll l = 0, r = 1e14;
while(l + 1 != r)
{
ll mid = (l + r) / 2;
if(check(mid) >= k)r = mid;//注意判断条件是>=
else l = mid;
}
cout << r << "\n";
return 0;
}