QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#723821 | #2940. Pooling PCR Tests | BackToSquare1 | AC ✓ | 0ms | 3940kb | C++20 | 1.2kb | 2024-11-08 00:57:48 | 2024-11-08 00:57:48 |
Judging History
answer
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef pair<ld,ld> pd;
typedef vector<ll> vl;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define G(x) ll x; cin >> x;
#define F(i, l, r) for (ll i = l; i < (r); ++i)
#define all(a) begin(a), end(a)
#define K first
#define V second
#define OK(i,j) i >= 0 && i < n && j >= 0 && j < m
#define NN 2505
#define MM 5005
#define MOD 1000007
void solve() {
ld p;
cin >> p;
ld q = 1.0 - p;
bool ok = 0;
ld ans = 1e9;
ll num = -1;
for(ll N = 2; N <= 16; N++) {
ld P = pow(q,N);
ld X = P + ((ld)N)*(1 - P);
if(X < (ld)N) {
ok = 1;
if(X < ans*((ld)N)) {
ans = X/((ld)N);
num = N;
}
}
}
if(!ok) cout << 1 << '\n';
else cout << num << '\n';
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(10);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
0.1
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
0.02
output:
8
result:
ok single line: '8'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
0.01
output:
10
result:
ok single line: '10'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
0.4
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
0.24
output:
3
result:
ok single line: '3'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
0.11
output:
4
result:
ok single line: '4'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
0.061
output:
5
result:
ok single line: '5'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
0.035
output:
6
result:
ok single line: '6'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
0.025
output:
7
result:
ok single line: '7'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
0.02
output:
8
result:
ok single line: '8'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
0.015
output:
9
result:
ok single line: '9'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.01
output:
10
result:
ok single line: '10'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.009
output:
11
result:
ok single line: '11'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
0.0075
output:
12
result:
ok single line: '12'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
0.006
output:
13
result:
ok single line: '13'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
0.0055
output:
14
result:
ok single line: '14'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
0.005
output:
15
result:
ok single line: '15'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
0.0033
output:
16
result:
ok single line: '16'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
0.001
output:
16
result:
ok single line: '16'