Advertisement
Guest User

Untitled

a guest
Dec 15th, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. //Lasha Bukhnikashvili
  2. #include<iostream>
  3. #include<stdio.h>
  4. #include<cstdlib>
  5. #include<math.h>
  6. #include<algorithm>
  7. #include<vector>
  8. #include<fstream>
  9. #include<string>
  10. #include<stack>
  11. #include <iomanip>
  12. #define pi 3.1415926535
  13. #define mod9 1000000009
  14. #define mod7 1000000007
  15. #define INF 1000000000
  16. #define starttime clock_t startTime = clock();
  17. #define endtime cout<< double(clock()-startTime)/(double)CLOCKS_PER_SEC<<"seconds."<<endl;
  18. using namespace std;
  19.  long long ans,i,mid,l,r,n,m,t[100001];
  20. int main(){
  21.  //freopen("input.txt","r",stdin);
  22.  //freopen("output.txt","w",stdout);
  23.    cin>>n>>m;
  24.    for (i=1;i<=n;i++)
  25.        cin>>t[i];
  26.    l=1; r=1000000000; r=r*r;
  27.    while (l<r){
  28.          ans=0;
  29.          mid=(l+r)/2;
  30.          for (i=1;i<=n;i++)
  31.              ans=ans+mid/t[i];
  32.          if (ans<m) l=mid+1; else r=mid;
  33.    };
  34.    cout<<l;
  35.  return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement