Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
cpp
main.cpp 2.9 kB 1 20-Aug-2015 17:35 filip_bujaroski Множење, Олимпијада

This page (revision-8) was last changed on 20-Aug-2015 17:35 by filip_bujaroski

This page was created on 20-Aug-2015 17:35 by bedzo

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 170 added 54 lines
!!Оценување
%%prettify
{{{
#include <iostream>
#include<string>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
long long n,k,ar[31],ans=LONG_LONG_MAX;
bool cc(long long a)
{
long long t = 0;
for(int i=0;i<n;i++) t+=a/ar[i];
if(t>=k) {
ans=min(a,ans);
return true;
}
return false;
}
void BS(long long a, long long b)
{
long long c=(a/2)+(b/2);
bool t=cc(c);
if(a!=b & c!=a & c!=b)
{
if(t)
{
BS(a,c);
}
else
{
BS(c,b);
}
}
}
int main()
{
cin>>n>>k;
for(int i=0;i<n;i++) cin>>ar[i];
BS(0,LONG_LONG_MAX);
cout<<ans<<endl;
return 0;
}
}}}
/%
Version Date Modified Size Author Changes ... Change note
8 20-Aug-2015 17:35 9.808 kB filip_bujaroski to previous
7 20-Aug-2015 17:35 6.838 kB bedzo to previous | to last
6 20-Aug-2015 17:35 5.588 kB bedzo to previous | to last
5 20-Aug-2015 17:35 5.47 kB bedzo to previous | to last
4 20-Aug-2015 17:35 6.684 kB bedzo to previous | to last
3 20-Aug-2015 17:35 5.873 kB bedzo to previous | to last
2 20-Aug-2015 17:35 5.851 kB bedzo to previous | to last
1 20-Aug-2015 17:35 0.516 kB bedzo to last
« This page (revision-8) was last changed on 20-Aug-2015 17:35 by filip_bujaroski