結果
問題 | No.1385 Simple Geometry 2 |
ユーザー |
![]() |
提出日時 | 2021-02-07 23:00:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,594 bytes |
コンパイル時間 | 3,553 ms |
コンパイル使用メモリ | 194,892 KB |
最終ジャッジ日時 | 2025-01-18 15:39:15 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 55 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 double theta[5001],r[5001]; int main(){ int N; cin>>N; long long L; cin>>L; double PI = acos(-1.0); vector<double> x(N),y(N); rep(i,N){ long long T; cin>>T; x[i] = cos(PI * 2.0 / L * T); y[i] = sin(PI * 2.0 / L * T); } double ans = 0.0; rep(i,N){ double temp = 0.0; /* rep(j,N){ if(j==0)continue; jj++; if(jj>=N)jj = 0; r[j-1] = hypot(x[i]-x[jj],y[i]-y[jj]); theta[j-1] = atan2(y[jj]-y[i],x[jj]-x[i]); } */ int pos = i+1; if(pos==N)pos = 0; double sp = 0.0,cp = 0.0,sm = 0.0,cm = 0.0; int cntp = 0,cntm = 0; int jj = i; rep(j,N-1){ jj++; if(jj>=N)jj = 0; while(pos!=jj){ if(sin(theta[jj]-theta[pos])<=0.0){ cntp--; cntm++; sp -= y[pos]-y[i];//sin(theta[pos])*r[pos]; cp -= x[pos]-x[i];//cos(theta[pos])*r[pos]; sm += y[pos]-y[i];//sin(theta[pos])*r[pos]; cm += x[pos]-x[i];//cos(theta[pos])*r[pos]; pos++; if(pos==N)pos = 0; } else break; } double ss = y[jj]-y[i];// double cc = x[jj]-x[i];//r[j] * sin(theta[j]),cc = r[j] * cos(theta[j]); double ttt = 0.0; if(j!=0){ ttt += ss * cp; ttt -= cc * sp; ttt -= ss * cm; ttt += cc * sm; //ttt *= cntp+cntm; } //cout<<ttt<<endl; temp += ttt; sp += ss; cp += cc; cntp ++; } temp /= N-1; temp *= 2.0; temp /= N-2; ans += temp/N; } ans /= 2.0; cout<<fixed<<setprecision(12)<<-ans<<endl; return 0; }