結果

問題 No.1385 Simple Geometry 2
ユーザー maple116maple116
提出日時 2021-02-07 21:35:46
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,357 bytes
コンパイル時間 8,040 ms
コンパイル使用メモリ 253,804 KB
最終ジャッジ日時 2025-01-18 14:36:08
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//g++ hoge.cpp (-std=c++17) -I . で実行
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define rept(itr,v) for(auto itr=v.begin();itr!=v.end();itr++)
#define rept1(itr,v) for(auto itr=v.begin()+1;itr!=v.end();itr++)
#define rept2(itr,v) for(auto itr=v.begin();itr!=v.end()-1;itr++)
#define print(x) cout << (x) << endl;
#define fprint(x) printf("%.15lf\n",(x));
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define YesNo(test) cout << ((test) ? "Yes" : "No") << endl
#define debug cout << "debug_print" << endl
#define Bint boost::multiprecision::cpp_int
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
ll myceil(ll a, ll b) { return (a+b-1) / b; }
//const ll mod = 1e9+7;
//const ll mod = 998244353;
//typedef modint1000000007 mint;
//typedef modint998244353 mint;
//typedef modint mint
//cout << sum.val() << endl;
//mint::set_mod(mod); modが固定でないとき

ll n;
const ll max_n = 500005;
double m,l,t[max_n],a[max_n],s[max_n],c[max_n];
double ss[max_n],sc[max_n],ss2[max_n],sc2[max_n];

int main() {
    // your code goes here
    cin >> n >> l;
    rep(i,1,n){
        cin >> t[i];
        a[i] = 2.0*atan2(0.0, -1.0)*t[i]/l;
        s[i] = sin(a[i]);
        ss[i] = ss[i-1] + s[i];
        c[i] = cos(a[i]);
        sc[i] = sc[i-1] + c[i];
    }
    m = n;
    sc2[1] = (2.0-m) * c[1];
    double ar1 = sc2[1] * s[2];
    //fprint(ar1);
    rep(i,3,n){
        //fprint(sc[i-2]);
        sc2[i-1] = sc2[i-2] + 2.0 * sc[i-2] + (2.0-m) * c[i-1];
        ar1 += sc2[i-1] * s[i];
    }
    ss2[1] = (2.0-m) * s[1];
    double ar2 = ss2[1] * c[2];
    rep(i,3,n){
        ss2[i-1] = ss2[i-2] + 2.0 * ss[i-2] + (2.0-m) * s[i-1];
        ar2 += ss2[i-1] * c[i];
    }
    ll ss = n * (n-1) * (n-2) / 6;
    fprint((ar2-ar1)/((double)ss*2.0));
    return 0;
}
0