QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371999#3001. Piece of CakeInfinityNS#WA 25ms3932kbC++14740b2024-03-30 19:11:392024-03-30 19:11:41

Judging History

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

  • [2024-03-30 19:11:41]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:3932kb
  • [2024-03-30 19:11:39]
  • 提交

answer

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

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

ldb fac[N];

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

ldb F(int p,int 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]);
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i;
	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: 3880kb

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: 25ms
memory: 3932kb

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