QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863780 | #3001. Piece of Cake | isWFnoya# | WA | 12ms | 71524kb | C++26 | 2.4kb | 2025-01-19 22:17:18 | 2025-01-19 22:17:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
int n,m,k;
// int a[N],b[N];
double a[N],b[N];
char s[N];
double C[3000][3000];
double pw[N];
bool check(double K,double B,double x,double y){
if(y>K*x+B) return true;
return false;
}
void __(){
// cin>>n>>m;
cin>>n>>m;
for(int i=1;i<=n;i++) scanf("%lf%lf",&a[i],&b[i]);
for(int i=1;i<=n*2;i++){
a[i+n]=a[i];
b[i+n]=b[i];
// a[i+n]=a[i];
// b[i+n]=b[i];
}
double ans=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(a[i]==a[j]) continue;
double K=(b[j]-b[i])/(a[j]-a[i]);
double B=b[i]-a[i]*K;
double res=(b[i]+b[j])*fabs(a[i]-a[j])/2;
// cout<<"--"<<res<<" ";
double rres=(C[j-i-1][m-2]-C[n-(j-i+1)][m-2])/C[n][m];
rres*=res;
// if(j==i+2){
// cout<<j-i-1<<" "<<m-2<<" "<<n-(j-i+1)<<" "<<C[j-i-1][m-2]/C[n][m]<<" "<<C[n-(j-i+1)][m-2]/C[n][m]<<endl;
// cout<<rres<<endl;
// }
// if(j==i+1){
bool flag=0;
if(j==i+n-1){
if(check(K,B,a[i+1],b[i+1])){
// double rres=
ans-=rres;
}else{
// double rres=(val[j-i-1][m-2]-val[n-(j-i+1)][m-2])*res;
ans+=rres;
}
}else
if(check(K,B,a[j+1],b[j+1])){
// double rres=
ans+=rres;
}else{
// double rres=(val[j-i-1][m-2]-val[n-(j-i+1)][m-2])*res;
ans-=rres;
}
// }
// cout<<i<<" "<<j<<" "<<rres<<" "<<ans<<endl;
}
}
printf("%.20f\n",ans);
}
int main(){
for(int i=0;i<=2550;i++){
C[i][0]=1;
}
for(int i=1;i<=2550;i++){
for(int j=1;j<=i;j++){
C[i][j]=(C[i-1][j]+C[i-1][j-1]);
}
}
pw[0]=1;
for(int i=1;i<=2550;i++) pw[i]=pw[i-1]*2;
// val[0][0]=0;
// for(int i=0;i<=10;i++){
// for(int j=0;j<=10;j++) cout<<val[i][j]<<" ";
// cout<<endl;
// }
int _=1;
// cin>>_;
while(_--){
__();
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 69608kb
input:
3 3 -5.236334 -8.519438 -9.987847 -0.492878 -9.994555 0.329962
output:
1.92794639621999985835
result:
ok found '1.9279464', expected '1.9279464', error '0.0000000'
Test #2:
score: 0
Accepted
time: 12ms
memory: 71524kb
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:
47.71453707055103876655
result:
ok found '47.7145371', expected '47.7145371', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 9ms
memory: 69476kb
input:
2099 1049 -9.999906 0.043015 -9.999734 0.072371 -9.999721 0.074260 -9.999602 0.089189 -9.999407 0.108349 -9.999328 0.115856 -9.998818 0.153747 -9.998136 0.193060 -9.997663 0.216208 -9.997463 0.225142 -9.996961 0.246480 -9.995978 0.282576 -9.995847 0.287087 -9.995567 0.296415 -9.994353 0.335674 -9.99...
output:
-nan
result:
wrong output format Expected double, but "-nan" found