不是说标准答案+0.01 or -0.01算通过吗
  • 板块P1577 切绳子
  • 楼主hecien
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/6/18 13:06
  • 上次更新2023/10/23 12:51:21
查看原帖
不是说标准答案+0.01 or -0.01算通过吗
26314
hecien楼主2023/6/18 13:06

测试数据8: in:

10000 999

1.00

1.00

1.00

1.00

1.00

1.00

1.00

1.00

1.00

...

out: 1.00

我的答案:1.01

为什么不算对呢?

系统的解释:Wrong Answer.wrong answer The answer is wrong: expected = 1.000000, found = 1.010000

附上程序:

#include <bits/stdc++.h>
using namespace std;
const long long int maxn=10000000+7;
int n,k;
double l[maxn];
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	cin>>n>>k;
	for(int i=1;i<=n;++i)cin>>l[i];
	long long int mid,s=0,e=maxn-7,ans=0;
	while(s<e){
//		cout<<s<<' '<<e<<endl;
		int sum=0;			
		mid=(s+e)/2;
		for(int i=1;i<=n;++i){
			sum+=(l[i]*100)/mid;
		}
		if(sum>=k){
			s=mid+1;
		}
		else if(sum<k){
			e=mid;
		}
	}
	printf("%.2lf\n",(double)((mid*1.0)/(100*1.0)));
	return 0;
}
2023/6/18 13:06
加载中...