結果

問題 No.1009 面積の求め方
ユーザー oooooba
提出日時 2021-05-22 19:56:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 111,680 KB
最終ジャッジ日時 2025-01-21 17:14:24
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t a, b;
    cin >> a >> b;
    double ans = 0;
    const auto N = int32_t(1e6);
    auto f = [&](double x) { return (x - a) * (x - b); };
    for (auto i = 0; i < N; ++i) {
        double d = double(b - a) / N;
        double s = d * abs(f(a + d * i));
        ans += s;
    }
    printf("%.9f\n", ans);
    return 0;
}
0