Advertisement
PikMike

Untitled

Jan 21st, 2017
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define pb push_back
  4. #define mp make_pair
  5. #define sz(x) (int)(x).size()
  6. #define li long long
  7. #define ld long double
  8. #define x first
  9. #define y second
  10. #define pt pair<int, int>
  11. #define pll pair<ll, ll>
  12. #define forn(i, t) for(int i = 0; i < (t); i++)
  13. #define fore(i, f, t) for(int i = (f); i < (t); i++)
  14. #define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
  15. #define all(x) (x).begin(), (x).end()
  16. #define ins insert
  17.  
  18. using namespace std;
  19.  
  20.  
  21. const int INF = 1e9;
  22. const int MOD = 1e9 + 7;
  23. const li INF64 = 1e18;
  24. const ld EPS = 1e-7;
  25.  
  26. mt19937 myrand(time(NULL));
  27.  
  28. int n, m, k;
  29.  
  30.  
  31. bool read(){
  32.     if(scanf("%d%d%d", &n, &m, &k) != 3)
  33.         return 0;
  34.     return 1;
  35. }
  36.  
  37.  
  38. void solve(int num){
  39.     int ans = INF;
  40.     if (n >= 2 * k + 3 && m >= k + 1)
  41.         ans = min(ans, (m + k - 1) / k);
  42.     if (m >= 2 * k + 3 && n >= k + 1)
  43.         ans = min(ans, (n + k - 1) / k);
  44.     if (n >= 4 * k + 1 && m >= k + 2)
  45.         ans = min(ans, 5);
  46.     if (m >= 4 * k + 1 && n >= k + 2)
  47.         ans = min(ans, 5);
  48.     if (n >= 3 * k + 1 && m >= k + 2 && k > 1)
  49.         ans = min(ans, 4);
  50.     if (m >= 3 * k + 1 && n >= k + 2 && k > 1)
  51.         ans = min(ans, 4);
  52.     printf("Case #%d: ", num);
  53.     printf("%d\n", ans == INF ? -1 : ans);
  54. }
  55.  
  56.  
  57. int main(){
  58.     #ifdef _DEBUG
  59.         freopen("subtle_sabotage.txt", "r", stdin);
  60.     #endif
  61.     int n;
  62.     scanf("%d", &n);
  63.     forn(i, n){
  64.         read();
  65.         solve(i + 1);
  66.     }
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement