結果

問題 No.1319 最強とんがりコーン
ユーザー hitonanodehitonanode
提出日時 2020-12-16 01:51:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 48,384 KB
最終ジャッジ日時 2025-01-17 01:41:36
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 70
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%lf%lf%lf", &R, &H, &D);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cmath>
#include <cstdio>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

int main()
{
    double R, H, D;
    scanf("%lf%lf%lf", &R, &H, &D);

    constexpr int Z = 1 << 9;
    const double T = D / (2 * R);
    double ret = 0.0;

    const double lo = T;
    const double dz = 1.0 / Z;
    REP(t, Z) {
        double u = 1.0 - (dz * dz * (t + 0.5) * (t + 0.5)) * (1 - lo);
        double dd = 2 * dz * dz * (t + 0.5) * (1 - lo);
        double theta = acos(T / u);
        ret += u * u * (theta * 0.5 - sin(theta * 2) * 0.25) * dd;
    }
    printf("%.15lf\n", ret * 4 * R * R * H);
}
0