CF-1013-D. Place of the Olympiad · znzryb
## 思路讲解
这个还是要写的更细致一点,检查函数
```cpp
inline bool check(ll x){
// ll res=ceil((M*N)*1.0l/(x+1));
// ll rem=K%x;
ll res=x*(M/(x+1));
ll usedBlock=(x+1)*(M/(x+1));
res+=max(0ll,(M-usedBlock));
// #ifdef LOCAL
// cerr << x<<" "<< res << '\n';
// #endif
if(res*N>=K){
return true;
}
return false;
}
```
## AC代码
::: 源代码
```cpp
// Problem: D. Place of the Olympiad
// Contest: Codeforces - Codeforces Round 1013 (Div. 3)
// URL: https://codeforces.com/contest/2091/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// by znzryb
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ROF(i, a, b) for (int i = (a); i >= (b); --i)
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define fi first
#define se second
#define pb push_back
#define SZ(a) ((int) a.size())
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
typedef pair<ll,ll> pll;
typedef array<ll,3> arr;
typedef double DB;
typedef pair<DB,DB> pdd;
typedef pair<ll,bool> plb;
constexpr ll MAXN=static_cast<ll>(1e6)+10,INF=static_cast<ll>(5e18)+3;
constexpr ll mod=static_cast<ll>(1e9)+7;
ll N,M,K,T,A[MAXN];
inline bool check(ll x){
// ll res=ceil((M*N)*1.0l/(x+1));
// ll rem=K%x;
ll res=x*(M/(x+1));
ll usedBlock=(x+1)*(M/(x+1));
res+=max(0ll,(M-usedBlock));
// #ifdef LOCAL
// cerr << x<<" "<< res << '\n';
// #endif
if(res*N>=K){
return true;
}
return false;
}
inline void solve(){
cin>>N>>M>>K;
ll l=0,r=K;
while(l<r){
ll mid=l+r>>1;
if(check(mid)){
r=mid;
}else{
l=mid+1;
}
}
cout<<l<<"\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
solve();
}
// solve();
return 0;
}
/*
AC
https://codeforces.com/contest/2091/submission/315860650
*/
```
:::
## 心路历程(WA,TLE,MLE……)