結果

問題 No.1319 最強とんがりコーン
コンテスト
ユーザー lam6er
提出日時 2025-03-31 17:46:34
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,186 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 84,516 KB
最終ジャッジ日時 2026-07-08 05:11:20
合計ジャッジ時間 9,889 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 70
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

def calculate_volume(R, H, D):
    a = D / (2 * R)
    if a >= 1:
        return 0.0
    t_max = 1 - a

    # Define the integrand for I1
    def integrand(t):
        s = 1 - t
        if s < a:
            return 0.0
        arg = a / s
        if arg >= 1:
            return 0.0
        return (s ** 2) * math.acos(arg)

    # Numerical integration using Simpson's rule for I1
    n = 1000000  # Adjust this number based on required precision and speed
    a_int = 0.0
    b_int = t_max
    h = (b_int - a_int) / n
    total = integrand(a_int) + integrand(b_int)
    for i in range(1, n):
        t = a_int + i * h
        coeff = 4 if i % 2 == 1 else 2
        total += coeff * integrand(t)
    I1 = h * total / 3

    # Calculate I2 using the derived formula
    sqrt_term = math.sqrt(1 - a**2)
    log_term = math.log((1 + sqrt_term) / a) if a != 0 else 0
    I2 = R * sqrt_term - R * a**2 * log_term

    # Calculate the volume
    volume = H * (2 * R**2 * I1 - (D / 2) * I2)
    return volume

# Read input
R, H, D = map(float, input().split())

# Compute the volume
vol = calculate_volume(R, H, D)

# Output with sufficient precision
print("{0:.12f}".format(vol))
0