読者です 読者をやめる 読者になる 読者になる

Facebook Hacker Cup 2017 round2

f:id:gasin:20170122135544p:plain

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N (1<<19)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

void solve(){
    int n, m, k;
    cin >> n >> m >> k;
    int ans = INF;
    if(n >= 2*k+1 && m >= 2*k+3){
        if(k >= 2) ans = min(ans,4);
        else ans = min(ans,5);
    }
    if(n >= 2*k+3 && m >= k-1) ans = min(ans,(m+k-1)/k);
    swap(n,m);
    if(n >= 2*k+1 && m >= 2*k+3){
        if(k >= 2) ans = min(ans,4);
        else ans = min(ans,5);
    }
    if(n >= 2*k+3 && m >= k-1) ans = min(ans,(m+k-1)/k);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

int main(){
    int T;
    cin >> T;
    rep(i,T){
        cout << "Case #" << i+1 << ": ";
        solve();
    }
}

""""""""""""m >= k-1""""""""""""