QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372001#3001. Piece of CakeInfinityNS#WA 1458ms62184kbC++14864b2024-03-30 19:14:472024-03-30 19:14:47

Judging History

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

  • [2024-03-30 19:14:47]
  • 评测
  • 测评结果:WA
  • 用时:1458ms
  • 内存:62184kb
  • [2024-03-30 19:14:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ldb long double

const int N=2505;
ldb x[N],y[N];

ldb fac[N][N];

ldb cross(int i,int j){
	return x[i]*y[j]-y[i]*x[j];
}

ldb F(int p,int q){
	if(p>=q)return fac[q][p];
	else return 1.0/fac[p][q];
	//return fac[p]/fac[q];
	//ldb ans=1;
	//for(int i=p+1;i<=q;i++)ans/=i;
	//for(int i=q+1;i<=p;i++)ans*=i;
	//return ans;
}
int main(){
	int n,k;
	scanf("%i %i",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%Lf %Lf",&x[i],&y[i]);
	}

	for(int i=0;i<=n;i++){
		fac[i][i]=1;
		for(int j=i+1;j<=n;j++){
			fac[i][j]=fac[i][j-1]*j;
		}
	}

	ldb ans=0;
	for(int i=0;i<n;i++){
		for(int sz=2;sz<=n;sz++){
			int j=(i+sz-1)%n;
			if(n-sz>=k-2){
				ans-=cross(i,j)*0.5*F(n-sz,n)*F(k,k-2)*F(n-k,n-sz-k+2);
			}
		}
	}
	printf("%.12Lf\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3900kb

input:

3 3
-5.236334 -8.519438
-9.987847 -0.492878
-9.994555 0.329962

output:

1.927946396220

result:

ok found '1.9279464', expected '1.9279464', error '0.0000000'

Test #2:

score: -100
Wrong Answer
time: 1458ms
memory: 62184kb

input:

2496 3
-9.999961 0.028130
-9.999655 0.083151
-9.999641 0.084830
-9.999572 0.092537
-9.999474 0.102653
-9.999366 0.112678
-9.999329 0.115862
-9.998360 0.181104
-9.998033 0.198381
-9.997191 0.237035
-9.995264 0.307754
-9.993680 0.355494
-9.992454 0.388414
-9.992180 0.395407
-9.992030 0.399190
-9.99086...

output:

-nan

result:

wrong output format Expected double, but "-nan" found