結果
問題 | No.1385 Simple Geometry 2 |
ユーザー |
|
提出日時 | 2024-02-25 03:43:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 327 ms / 500 ms |
コード長 | 1,856 bytes |
コンパイル時間 | 356 ms |
コンパイル使用メモリ | 82,836 KB |
実行使用メモリ | 222,628 KB |
最終ジャッジ日時 | 2024-09-29 10:41:58 |
合計ジャッジ時間 | 26,638 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 65 |
ソースコード
## https://yukicoder.me/problems/no/1385import mathdef main():N, L = map(int, input().split())T = list(map(int, input().split()))# sin, cosの累積和f_list = [0] * Ng_list = [0] * Nf = 0g = 0for i in reversed(range(N)):t = (2 * math.pi * T[i]) / Lf += math.sin(t)g += math.cos(t)f_list[i] = fg_list[i] = g# 複雑な計算式の累積和x_cum_list = [0] * Nx_cum = 0xcos_cum_list = [0] * Nxcos_cum = 0xsin_cum_list = [0] * Nxsin_cum = 0ysin_cum_list = [0] * Nysin_cum = 0ycos_cum_list = [0] * Nycos_cum = 0for i in reversed(range(N - 1)):f = f_list[i + 1]g = g_list[i + 1]t = (2 * math.pi * T[i]) / Lcos_t = math.cos(t)sin_t = math.sin(t)x = f * cos_t - g * sin_ty = (N - 1 - i) - g * cos_t - f * sin_tx_cum += xx_cum_list[i] = x_cumxcos_cum += x * cos_txcos_cum_list[i] = xcos_cumxsin_cum += x * sin_txsin_cum_list[i] = xsin_cumysin_cum += y * sin_tysin_cum_list[i] = ysin_cumycos_cum += y * cos_tycos_cum_list[i] = ycos_cum#cum_value_list = [0] * Nfor i in reversed(range(N - 2)):t = (2 * math.pi * T[i]) / Lcos_t = math.cos(t)sin_t = math.sin(t)value = x_cum_list[i + 1] / 2value -= xcos_cum_list[i + 1] * cos_t / 2value -= xsin_cum_list[i + 1] * sin_t / 2value += ysin_cum_list[i + 1] * cos_t / 2value -= ycos_cum_list[i + 1] * sin_t / 2cum_value_list[i] = valueans = (N * (N - 1) * (N - 2)) // 6answer = 0for i in range(N):answer += cum_value_list[i] / ansprint(answer)if __name__ == "__main__":main()