wangxx2012 @ 2024-11-14 13:17:56
传送门
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100010],cnt=1,maxn=INT_MAX,id;
double b[100010];
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>b[i];
a[i]=int(b[i]);
if(a[i]<maxn){
maxn=a[i];
id=i;
}
}
for(int i=a[id];i>=1;i--){
int ans=0;
for(int j=1;j<=n;j++) ans+=a[j]/i;
if(ans==k){
printf("%.2f",double(i));
break;
}
}
return 0;
}
by CarlosProvo @ 2024-11-14 14:00:47
你这做法包假的,这是二分答案
by 27maxuanwei @ 2024-11-15 09:34:20