結果

問題 No.1385 Simple Geometry 2
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-02-25 03:43:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 339 ms / 500 ms
コード長 1,856 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 221,984 KB
最終ジャッジ日時 2024-02-25 03:44:22
合計ジャッジ時間 25,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,844 KB
testcase_01 AC 33 ms
53,844 KB
testcase_02 AC 33 ms
53,844 KB
testcase_03 AC 36 ms
53,844 KB
testcase_04 AC 34 ms
53,844 KB
testcase_05 AC 36 ms
53,844 KB
testcase_06 AC 35 ms
53,844 KB
testcase_07 AC 35 ms
53,844 KB
testcase_08 AC 83 ms
66,804 KB
testcase_09 AC 55 ms
66,804 KB
testcase_10 AC 55 ms
66,804 KB
testcase_11 AC 54 ms
66,804 KB
testcase_12 AC 55 ms
66,804 KB
testcase_13 AC 311 ms
218,228 KB
testcase_14 AC 288 ms
218,196 KB
testcase_15 AC 312 ms
218,172 KB
testcase_16 AC 290 ms
218,208 KB
testcase_17 AC 290 ms
218,224 KB
testcase_18 AC 292 ms
218,036 KB
testcase_19 AC 339 ms
217,864 KB
testcase_20 AC 288 ms
218,192 KB
testcase_21 AC 288 ms
218,212 KB
testcase_22 AC 289 ms
217,212 KB
testcase_23 AC 316 ms
218,180 KB
testcase_24 AC 288 ms
217,344 KB
testcase_25 AC 287 ms
217,432 KB
testcase_26 AC 291 ms
218,172 KB
testcase_27 AC 315 ms
218,228 KB
testcase_28 AC 286 ms
217,496 KB
testcase_29 AC 290 ms
218,224 KB
testcase_30 AC 289 ms
218,188 KB
testcase_31 AC 313 ms
218,224 KB
testcase_32 AC 291 ms
218,160 KB
testcase_33 AC 290 ms
218,208 KB
testcase_34 AC 291 ms
217,996 KB
testcase_35 AC 317 ms
218,220 KB
testcase_36 AC 290 ms
218,192 KB
testcase_37 AC 290 ms
218,236 KB
testcase_38 AC 289 ms
218,216 KB
testcase_39 AC 312 ms
218,208 KB
testcase_40 AC 288 ms
218,180 KB
testcase_41 AC 289 ms
218,188 KB
testcase_42 AC 293 ms
218,016 KB
testcase_43 AC 317 ms
218,236 KB
testcase_44 AC 291 ms
218,240 KB
testcase_45 AC 288 ms
218,244 KB
testcase_46 AC 289 ms
218,236 KB
testcase_47 AC 309 ms
218,252 KB
testcase_48 AC 289 ms
218,244 KB
testcase_49 AC 290 ms
218,236 KB
testcase_50 AC 291 ms
218,236 KB
testcase_51 AC 291 ms
218,244 KB
testcase_52 AC 288 ms
218,248 KB
testcase_53 AC 288 ms
218,224 KB
testcase_54 AC 291 ms
218,236 KB
testcase_55 AC 289 ms
218,244 KB
testcase_56 AC 288 ms
218,248 KB
testcase_57 AC 289 ms
218,216 KB
testcase_58 AC 289 ms
218,244 KB
testcase_59 AC 265 ms
189,016 KB
testcase_60 AC 274 ms
217,696 KB
testcase_61 AC 277 ms
217,696 KB
testcase_62 AC 271 ms
217,696 KB
testcase_63 AC 314 ms
221,980 KB
testcase_64 AC 290 ms
221,976 KB
testcase_65 AC 288 ms
221,984 KB
testcase_66 AC 288 ms
221,976 KB
testcase_67 AC 304 ms
218,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/1385

import math

def main():
    N, L = map(int, input().split())
    T = list(map(int, input().split()))

    # sin, cosの累積和
    f_list = [0] * N
    g_list = [0] * N
    f = 0
    g = 0
    for i in reversed(range(N)):
        t = (2 * math.pi * T[i]) / L
        f += math.sin(t)
        g += math.cos(t)
        f_list[i] = f
        g_list[i] = g

    # 複雑な計算式の累積和
    x_cum_list = [0] * N
    x_cum = 0
    xcos_cum_list = [0] * N
    xcos_cum = 0
    xsin_cum_list = [0] * N
    xsin_cum = 0
    ysin_cum_list = [0] * N
    ysin_cum = 0
    ycos_cum_list = [0] * N
    ycos_cum = 0
    for i in reversed(range(N - 1)):
        f = f_list[i + 1]
        g = g_list[i + 1]
        t = (2 * math.pi * T[i]) / L
        cos_t = math.cos(t)
        sin_t = math.sin(t)

        x = f * cos_t - g * sin_t
        y = (N - 1 - i) - g * cos_t - f * sin_t

        x_cum += x
        x_cum_list[i] = x_cum
        xcos_cum += x * cos_t
        xcos_cum_list[i] = xcos_cum
        xsin_cum += x * sin_t
        xsin_cum_list[i] = xsin_cum
        ysin_cum += y * sin_t
        ysin_cum_list[i] = ysin_cum
        ycos_cum += y * cos_t
        ycos_cum_list[i] = ycos_cum

    # 
    cum_value_list = [0] * N
    for i in reversed(range(N - 2)):
        t = (2 * math.pi * T[i]) / L
        cos_t = math.cos(t)
        sin_t = math.sin(t)

        value = x_cum_list[i + 1] / 2
        value -= xcos_cum_list[i + 1] * cos_t / 2
        value -= xsin_cum_list[i + 1] * sin_t / 2
        value += ysin_cum_list[i + 1] * cos_t / 2
        value -= ycos_cum_list[i + 1] * sin_t / 2
        cum_value_list[i] = value

    ans = (N * (N - 1) * (N - 2)) // 6
    answer = 0
    for i in range(N):
        answer += cum_value_list[i] / ans 
    print(answer)






if __name__ == "__main__":
    main()
0