結果
問題 | No.1807 UMA Gacha |
ユーザー |
![]() |
提出日時 | 2021-09-26 16:54:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 809 bytes |
コンパイル時間 | 2,045 ms |
コンパイル使用メモリ | 191,976 KB |
最終ジャッジ日時 | 2025-01-24 18:28:09 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 8 WA * 13 |
ソースコード
#include <bits/stdc++.h>#define rep(i, l, n) for (int i = (l); i < (n); i++)using namespace std;using std::chrono::duration_cast;using std::chrono::milliseconds;using std::chrono::system_clock;inline int getnow() { return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); }//モンテカルロ法(精度は良くない)int main(void) {int stime = getnow();int n; cin >> n;double p; cin >> p;if (n >= 200) {cout << 1 << endl;return 0;}int cnt = 0;int a = 0;while (getnow() - stime < 1900) {cnt++;bool flag = false;rep(i, 0, n) {double r = double(rand()) / double(RAND_MAX);if (r < p) {flag = true;break;}}if (flag) {a++;}}double ans = double(a) / double(cnt);cout << ans << endl;return 0;}