Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

SC新开辟了一种错误方式、、网上都搜不到

Posted by imcaffrey at 2015-01-27 22:45:47 on Problem 1064
#include <cstdio>
#include <cstring>
// #include <algorithm>
// #include <cassert>
// using std::sort;
#include <cmath>
#define f(x,y,z) for(int x = (y),__ = (z);x < __;++x)
#define g(x,y,z) for(int x = (y),__ = (z);x <= __;++x)
#define fd(x,y,z) for(int x = (y),__ = (z);x > __;--x)
#define gd(x,y,z) for(int x = (y),__ = (z);x >= __;--x)
#define MAX 10024
#define EPS 1e-6
int n,k;
double len[MAX];
double ll = 0.0,rr,m(0.0);
inline bool check(double x){
	int tee = 0;
	f(i,0,n){
		tee += (int)(len[i] / x);
	}
	return tee >= k;
}
double sum,max;
int main(){
	scanf("%d%d",&n,&k);
	f(i,0,n){
		scanf("%lf",&len[i]);
		sum += len[i];
		if (max < len[i])max = len[i];
	}
	if (sum * 100 < k){
		puts("0.00");
		return 0;
	}
	rr = max;
	while (rr - ll > EPS){
		// m = ll + (rr - ll) / 2;
		m = (ll + rr) / 2.0;
		if (check(m))ll = m;
		else rr = m;
	}
	// if (ll >= 0.01)printf("%.2lf\n",ll);
	if (rr >= 0.01)printf("%.2lf\n",floor(rr * 100) / 100);
	// if (rr >= 0.01)printf("%.2lf\n",rr);
	else puts("0.00");
	return 0;
}

以上代码是二分的
AC
可是如果是把while循环改成for循环(100次),能过样例但是WA;
如果改成200次就连样例都过不了了…………

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator