Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<map>
- using namespace std;
- typedef long long int ll;
- bool debug = false;
- struct mycmp{
- bool operator() (const ll& lhs,const ll& rhs)const
- {
- return lhs > rhs;
- }
- };
- int main()
- {
- int T;
- scanf("%d",&T);
- map<ll,ll,mycmp> map;
- for(int t = 1; t <= T ;t ++){
- ll n,k;
- scanf("%lld %lld",&n,&k);
- map.clear();
- map[n] = 1;
- ll i = 0;
- std::map<ll,ll>::iterator it;
- ll RE,LE;
- while(i < k){
- it = map.begin();
- ll len = it->first;
- ll cnt = it->second;
- ll mid = (len + 1)/2;
- RE = len - mid;
- LE = mid - 1;
- if(debug)printf("Test Case #%d : i = %d , len = %lld , cnt = %lld , mid = %lld , RE = %lld , LE = %lld\n",t,i,len,cnt,mid,RE,LE);
- map.erase(len);
- map[RE] += cnt;
- map[LE] += cnt;
- i += cnt;
- }
- printf("Case #%d: %lld %lld\n",t,RE,LE);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment