QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397166#4392. BowcraftDiuAC ✓171ms4436kbC++14764b2024-04-23 18:47:502024-04-23 18:47:51

Judging History

你现在查看的是最新测评结果

  • [2024-04-23 18:47:51]
  • 评测
  • 测评结果:AC
  • 用时:171ms
  • 内存:4436kb
  • [2024-04-23 18:47:50]
  • 提交

answer

#include<bits/stdc++.h>
#define db long double
using namespace std;
const int N=10010;
const db Inf=1e9;
int T;
int n,A,B;
db f[N];
struct node{
	db p,q,val;
	bool operator<(const node h)const{
		return val<h.val;
	}
}t[N];
signed main(){
	scanf("%d",&T);
	for(;T--;){
		scanf("%d%d%d",&n,&A,&B);
		f[0]=0;
		int tot=0;
		for(int a=1;a<A;a++)
			for(int b=0;b<B;b++){
				++tot;
				t[tot].p=(db)a/(db)A;
				t[tot].q=(db)b/(db)B;
				t[tot].val=(t[tot].q-t[tot].p*t[tot].q)/t[tot].p;
			}
		sort(t+1,t+tot+1);
		for(int i=1;i<=n;i++){
			db s1=0,s2=0;
			f[i]=Inf;
			for(int j=1;j<=tot;j++){
				s1+=t[j].p+t[j].q-t[j].p*t[j].q;
				s2+=t[j].p;
				f[i]=min(f[i],(A*B+f[i-1]*s1)/s2);
			}
		}
		printf("%.3Lf\n",f[n]);
	}
}

详细

Test #1:

score: 100
Accepted
time: 171ms
memory: 4436kb

input:

10
996 99 66
904 99 86
609 85 57
729 63 57
617 78 72
751 81 89
952 93 94
791 58 66
726 94 75
1000 100 100

output:

77416.113
75591.341
35314.209
48508.448
40062.330
58921.716
85820.717
59676.753
51117.885
93950.049

result:

ok 10 lines