QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73207#2940. Pooling PCR Testsqdd#AC ✓2ms3760kbC++20880b2023-01-23 05:08:252023-01-23 05:08:29

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-23 05:08:29]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3760kb
  • [2023-01-23 05:08:25]
  • 提交

answer

// qdd on Jan 22, 2023

#ifdef qdd
#include <ringo>
#else
#include <bits/stdc++.h>
#define dbg(...)
#define dbgr(x, y)
#endif

using namespace std;

using ll = long long;

#define ALL(x) begin(x), end(x)

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v) is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool f = 0;
  for (const T& x : v) (f ? os << ' ' : os) << x, f = 1;
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double p;
  cin >> p;
  double q = 1 - p;
  pair<double, int> ans = {1, 1};
  for (int n = 2; n <= 16; n++) {
    double P = pow(q, n);
    double et = P + n * (1 - P);
    if (ans.first > et / n + 1e-6) {
      ans = make_pair(et / n, n);
    }
  }
  cout << ans.second << '\n';
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3736kb

input:

0.1

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

0.02

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

0.01

output:

10

result:

ok single line: '10'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

0.4

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

0.24

output:

3

result:

ok single line: '3'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

0.11

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

0.061

output:

5

result:

ok single line: '5'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

0.035

output:

6

result:

ok single line: '6'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3656kb

input:

0.025

output:

7

result:

ok single line: '7'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

0.02

output:

8

result:

ok single line: '8'

Test #11:

score: 0
Accepted
time: 2ms
memory: 3724kb

input:

0.015

output:

9

result:

ok single line: '9'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

0.01

output:

10

result:

ok single line: '10'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

0.009

output:

11

result:

ok single line: '11'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3720kb

input:

0.0075

output:

12

result:

ok single line: '12'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

0.006

output:

13

result:

ok single line: '13'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

0.0055

output:

14

result:

ok single line: '14'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

0.005

output:

15

result:

ok single line: '15'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3760kb

input:

0.0033

output:

16

result:

ok single line: '16'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

0.001

output:

16

result:

ok single line: '16'