小白月赛47 解説と実装
A. ボール詰めゲーム
円柱に詰め込めるボールの体積を求める。円柱の体積は πr²h、各ボールの体積は 4/3 πr³。高さ h の中に収まるボール数は ⌊h/(2r)⌋ 個なので、答えは
πr²h − ⌊h/(2r)⌋ · 4/3 πr³
である。計算量は O(1)。
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
int main() {
ios::sync_with_stdio(fals ...
7月14日 22:37 投稿