結果
| 問題 |
No.1319 最強とんがりコーン
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:46:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 2,000 ms |
| コード長 | 1,186 bytes |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 82,424 KB |
| 実行使用メモリ | 76,584 KB |
| 最終ジャッジ日時 | 2025-03-31 17:47:19 |
| 合計ジャッジ時間 | 8,378 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 70 |
ソースコード
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))
lam6er