Advertisement
Guest User

bullseye

a guest
Apr 20th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7.     int T;
  8.     int prob=1;
  9.     for(cin>>T;T>0;T--)
  10.     {
  11.         unsigned long long r,t;
  12.         cin>>r>>t;
  13.         unsigned long long lo=0;
  14.         unsigned long long hi=1e15;
  15.         unsigned long long x;
  16.         while(hi>lo)
  17.         {
  18.             x=(hi+lo+1)/2;
  19.             if ((double)x * (1 + 2*r + (2*x-2)) > t+1e18 ||
  20.                         x * (1 + 2*r + (2*x-2)) > t)
  21.                 hi=x-1;
  22.             else
  23.             {
  24.                 lo=x;
  25.             }
  26.         }
  27.         cout<<"Case #"<<prob<<": "<<lo<<"\n";
  28.         prob++;
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement