Advertisement
wgma

Untitled

Apr 8th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define inf 0x3f3f3f3f
  3. #define mp make_pair
  4. #define pb push_back
  5. #define MAX_BITS 1000
  6. using namespace std;
  7.  
  8. int T, N, K;
  9.  
  10. int main(){
  11.     cin >> T;
  12.     for(int t = 1; t <= T;t++){
  13.         cin >> N >> K;
  14.         priority_queue<int>pq;
  15.         int ret;
  16.         pq.push(N);
  17.         for(int k = 0;k < K && !pq.empty();k++){
  18.             int best = pq.top();
  19.             ret = best;
  20.             pq.pop();
  21.             if(best % 2 == 0){
  22.                 pq.push(best/2);
  23.                 pq.push(best/2-1);
  24.             }else{
  25.                 pq.push(best/2);
  26.                 pq.push(best/2);
  27.             }
  28.         }
  29.         int max_lr =0, min_lr=0;
  30.         if(ret % 2 == 0 && ret != 0){
  31.             max_lr = max(ret/2, ret/2-1);
  32.             min_lr = min(ret/2, ret/2-1);
  33.         } else{
  34.             max_lr = max(ret/2, ret/2);
  35.             min_lr = min(ret/2, ret/2);
  36.         }
  37.         cout << "Case #" << t << ": " << max_lr << " " << min_lr  << endl;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement