結果

問題 No.2971 無理積分
ユーザー Tatsu_mr
提出日時 2025-02-12 00:15:09
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 106 ms / 1,000 ms
コード長 1,615 bytes
コンパイル時間 3,478 ms
コンパイル使用メモリ 277,180 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-12 00:15:17
合計ジャッジ時間 6,702 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) For(i, 0, n)
#define rFor(i, a, b) for(int i = (a); i >= (b); i--)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()
using lint = long long;
using ld = long double;
int INF = 2000000000;
lint LINF = 1000000000000000000;
struct SetupIo {
SetupIo() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} setupio;
unsigned int xorshift() {
static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
unsigned int t = (x ^ (x << 11));
x = y;
y = z;
z = w;
return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int rnd(int l, int r) {
int res = xorshift() % (r - l);
return res + l;
}
int main() {
int n;
cin >> n;
ld n3 = ld(n) * ld(n) * ld(n);
ld mny = sqrt(n3), mxy = sqrt(n3 + 1.0);
int l = ceil(mny * 10000), r = floor(mxy * 10000);
if (l >= r) {
cout << mny << "\n";
return 0;
}
auto get_x = [&]() -> ld {
ld x = rnd(0, 10000);
x /= 10000.0;
return x;
};
auto get_y = [&]() -> ld {
ld y = rnd(l, r);
y /= 10000.0;
return y;
};
auto in = [&](ld x, ld y) -> bool {
ld fx = sqrt(x * x * x + n3);
return y <= fx;
};
int all = 10000000, cnt = 0;
rep(_, all) {
ld x = get_x(), y = get_y();
if (in(x, y)) {
cnt++;
}
}
cout << mny + ld(cnt) / ld(all) * (mxy - mny) << "\n";
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0