QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54837#55. 欧几里得距离之和AFewSuns#0 642ms3792kbC++1.7kb2022-10-10 20:02:072022-10-10 20:02:08

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-10 20:02:08]
  • 评测
  • 测评结果:0
  • 用时:642ms
  • 内存:3792kb
  • [2022-10-10 20:02:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll int
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db long double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
ll n,x[500050],y[500050],lim=200;
db pi=acos(-1.0),p[500050],ans=0;
int main(){
	n=read();
	fr(i,1,n){
		x[i]=read();
		y[i]=read();
	}
	if(n<=5000){
		fr(i,1,n) fr(j,i+1,n) ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		pf("%.7Lf",ans);
	}
	else{
		fr(i,0,lim-1){
			db cs=cos(2*pi/lim*i),sn=sin(2*pi/lim*i);
			fr(j,1,n) p[j]=x[j]*cs-y[j]*sn;
			sort(p+1,p+n+1);
			fr(j,1,n) ans+=1.0*(2*j-n-1)*p[j];
		}
		pf("%.7Lf",ans/(db)lim*pi/2.0);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 642ms
memory: 3792kb

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%