結果

問題 No.2352 Sharpened Knife in Fall
ユーザー FromBooska
提出日時 2023-06-17 11:27:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 465 ms / 3,000 ms
コード長 815 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 79,996 KB
最終ジャッジ日時 2024-06-25 02:56:57
合計ジャッジ時間 12,551 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

# 円の上半分でy座標を求めて、あとはミラーで下半分作る
# Kが奇数ならy=0が含まれる
# 二分探索で求めるか
# あるyで切ったときの上のケーキの面積は
# S = theta*R**2 - y*R*sintheta where theta = arccos(y/R)

R, K = map(int, input().split())

import math

def calc_area(y):
    theta = math.acos(y/R)
    area = theta*(R**2) - y*R*math.sin(theta)
    return area

ans_list = []
if K%2 == 1:
    ans_list.append(0)
for k in range(K//2):
    find = math.pi*(R**2)*((k+1)/(K+1))
    OK = R
    NG = 0
    for i in range(100):
        mid = (OK+NG)/2
        if calc_area(mid) <= find:
            OK = mid
        else:
            NG = mid
    ans_list.append(OK)
    ans_list.append(-OK)
    
ans_list.sort()
#print(ans_list)

for a in ans_list:
    print(a)



0