AhmedAshraff

Untitled

May 10th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2. #define boAshraf ios_base::sync_with_stdio(false); cin.tie(NULL);
  3. #define ll long long
  4. #define sz(s) (int)(s).size()
  5. #define all(s) (s).begin(),(s).end()
  6. using namespace std;
  7. void File();
  8. void sol();
  9. const long double pi = acos(-1);
  10. int main() {
  11.     boAshraf
  12.     File();
  13.     int t = 1;
  14.     cin >> t;
  15.     while (t--) {
  16.         sol();
  17.     }
  18.     return 0;
  19. }
  20.  
  21. void sol() {
  22.     ll n,m,R;
  23.     cin>>n>>m>>R;
  24.     auto valid=[&](ll mid)->bool{
  25.         long double tot=mid*2*pi*R+(mid)*(mid-1)*pi*m;
  26.         return tot>=n;
  27.     };
  28.     ll l=1,r=1e9,ans=-1;
  29.     while(l<=r){
  30.         ll mid=(l+r)/2;
  31.         if(valid(mid))ans=mid,r=mid-1;
  32.         else l=mid+1;
  33.     }
  34.     cout<<R+(ans-1)*m<<'\n';
  35. }
  36.  
  37. void File() {
  38. #ifndef ONLINE_JUDGE
  39.     freopen("input.txt", "r", stdin);
  40.     freopen("output.txt", "w", stdout);
  41. #endif
  42. }
Advertisement
Add Comment
Please, Sign In to add comment