POJ 1064 Cable master
阿新 • • 發佈:2018-05-12
lse cab ++i code left con max include d+
……
精度各種鍋
轉了int再判終於對了
還有cin cout 被卡
傷心
#include <cstdio> using namespace std; const int MAXN=10011; double input; int N, K; int Num[MAXN]; int Left, Right, Mid; bool Test(int k){ int c=0; for(int i=1;i<=N;++i){ c+=Num[i]/k; } return c>=K; } int main(){ while(scanf("%d%d", &N, &K)!=EOF){ for(int i=1;i<=N;++i){ scanf("%lf", &input); Num[i]=(int)(input*100.0); } Left=0;Right=0; for(int i=1;i<=N;++i) if(Num[i]>Right) Right=Num[i]; while(Left<Right){ Mid=(Left+Right)>>1; if(Test(Mid+1)) Left=Mid+1; else Right=Mid; } Mid=(Left+Right)>>1; printf("%d.%d%d\n", Mid/100, (Mid/10)%10, Mid%10); } return 0; }
POJ 1064 Cable master