QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55574#55. 欧几里得距离之和CharlieVinnie0 3ms3664kbC++201.3kb2022-10-14 16:35:092022-10-14 16:35:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-14 16:35:11]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:3664kb
  • [2022-10-14 16:35:09]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std;
// #define cout Cout
const int N=5e5+5; typedef long long ll; const double PI=acos(-1.0);
int read()
{
    bool neg=false;
    char Charlie;
    while((Charlie=getchar())<'0'||Charlie>'9'){
        if(Charlie=='-') neg=true;
    }
    int Vinnie=Charlie-'0';
    while((Charlie=getchar())>='0'&&Charlie<='9') Vinnie=(Vinnie<<3)+(Vinnie<<1)+Charlie-'0';
    return neg?-Vinnie:Vinnie;
}
int n,px[N],py[N]; double tx[N];
signed main(){
    n=read(); For(i,1,n) { px[i]=read(); py[i]=read(); }
    if(n<=4000){
        double ans=0.0; For(i,1,n) For(j,i+1,n) ans+=sqrt((px[i]-px[j])*(px[i]-px[j])+(py[i]-py[j])*(py[i]-py[j]));
        cout<<setprecision(20)<<fixed<<ans<<'\n'; return 0;
    }
    int T=100; double dx=2*PI/T,ans=0.0;
    For(i,0,T-1){
        double th=(i+0.5)*dx,costh=cos(th),sinth=sin(th);
        For(j,1,n) tx[j]=px[j]*costh-py[j]*sinth;
        sort(tx+1,tx+1+n); For(j,1,n) ans+=((j-1)-(n-j))*tx[j];
    }
    cout<<setprecision(20)<<fixed<<ans*dx/4<<'\n';
    cerr<<"Time = "<<clock()<<" ms"<<endl;
    return 0;
}

// START TYPING IF YOU DON'T KNOW WHAT TO DO

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3664kb

input:

3000
-802420 -321989
227507 956314
-460698 -819834
-479809 -341770
191520 109304
712327 -189558
-578326 -41090
282566 982266
-859119 686756
209058 -23298
-884994 -349898
-11358 182915
-507706 -81622
745434 575941
-374809 139274
810223 367608
960234 -197223
439081 573568
-275182 999306
-583036 -61808...

output:

-nan

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%