Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define mp make_pair
- #define sz(x) (int)(x).size()
- #define li long long
- #define ld long double
- #define x first
- #define y second
- #define pt pair<int, int>
- #define pll pair<ll, ll>
- #define forn(i, t) for(int i = 0; i < (t); i++)
- #define fore(i, f, t) for(int i = (f); i < (t); i++)
- #define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
- #define all(x) (x).begin(), (x).end()
- #define ins insert
- using namespace std;
- const int INF = 1e9;
- const int MOD = 1e9 + 7;
- const li INF64 = 1e18;
- const ld EPS = 1e-7;
- mt19937 myrand(time(NULL));
- int n, m, k;
- bool read(){
- if(scanf("%d%d%d", &n, &m, &k) != 3)
- return 0;
- return 1;
- }
- void solve(int num){
- int ans = INF;
- if (n >= 2 * k + 3 && m >= k + 1)
- ans = min(ans, (m + k - 1) / k);
- if (m >= 2 * k + 3 && n >= k + 1)
- ans = min(ans, (n + k - 1) / k);
- if (n >= 4 * k + 1 && m >= k + 2)
- ans = min(ans, 5);
- if (m >= 4 * k + 1 && n >= k + 2)
- ans = min(ans, 5);
- if (n >= 3 * k + 1 && m >= k + 2 && k > 1)
- ans = min(ans, 4);
- if (m >= 3 * k + 1 && n >= k + 2 && k > 1)
- ans = min(ans, 4);
- printf("Case #%d: ", num);
- printf("%d\n", ans == INF ? -1 : ans);
- }
- int main(){
- #ifdef _DEBUG
- freopen("subtle_sabotage.txt", "r", stdin);
- #endif
- int n;
- scanf("%d", &n);
- forn(i, n){
- read();
- solve(i + 1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement