Advertisement
Mohammad_Rakib

G. Smallest Product

Dec 24th, 2020
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. // Bismillahir Rahmanir Rahim
  2. //============================
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. #define ll          long long
  7. #define endl        "\n"
  8. #define infL        LLONG_MAX
  9. #define infI        INT_MAX
  10. #define pb          push_back
  11. #define fo(i,a,b) for(int i=a;i<b;i++)
  12. #define precise(x,y)cout<<fixed<<setprecision(y)<<x<<endl;
  13. #define MAX         20000000000
  14. #define yes         cout<<"YES"<<endl
  15. #define no          cout<<"NO"<<endl
  16. #define bye         return 0
  17. #define PEREGRINE_FALCON {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
  18.  
  19. ll mod=1e9+7;
  20. ll Pi =acos(-1);
  21. double epsilon = 0.0000001f;
  22.  
  23. ll lowerBinSrch(ll n, double sum)
  24. {
  25.       ll lo=1;
  26.       ll hi=MAX;
  27.       ll md,temp=2;
  28.       double k;
  29.  
  30.       while(lo<=hi){
  31.             md=lo+((hi-lo)/2);
  32.             k=n*(log10(md));
  33.             if(k>sum){
  34.                   temp=md;
  35.                   hi=md-1;
  36.             }
  37.             else{lo=md+1;}
  38.       }
  39.       return temp;
  40. }
  41.  
  42. int main()
  43. {
  44.       PEREGRINE_FALCON
  45.       //freopen("inputNew.txt", "r", stdin);
  46.  
  47.       ll testCase=1;
  48.       //cin>>testCase;
  49.       while(testCase--){
  50.             double m,k,x,y,z,a,b,c,d,mn,mx,temp,cnt,ans,sum,sz,len;
  51.             ll n;
  52.             cin>>n;
  53.             double arr[n];
  54.             sum=0;
  55.             for(int i=0; i<n; i++){
  56.                   cin>>arr[i];
  57.                   sum+=log10(arr[i]);
  58.             }
  59.             //cout<<"sum: "<<sum<<endl;
  60.  
  61.             cout<<(lowerBinSrch(n,sum))<<endl;
  62.       }
  63.  
  64.       bye;
  65. }
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement