QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#708787#2940. Pooling PCR Testssefnuray#AC ✓64ms54444kbJava111.6kb2024-11-04 06:36:542024-11-04 06:36:55

Judging History

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

  • [2024-11-04 06:36:55]
  • 评测
  • 测评结果:AC
  • 用时:64ms
  • 内存:54444kb
  • [2024-11-04 06:36:54]
  • 提交

answer

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class PCR {

    static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));

        double p = readDouble();
        double min = 1;
        int N = 1;
        for (int i = 2; i <= 16; i++) {
            double P = Math.pow(1 - p, i);
            double ET = 1 * P + i * (1 - P);
            double ratio = ET / i;
            if (ratio < min) {
                min = ratio;
                N = i;
            }
        }

        out.println(N);

        out.close();
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }

    static long readLong() throws IOException {
        return Long.parseLong(next());
    }

    static int readInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double readDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static char readCharacter() throws IOException {
        return next().charAt(0);
    }

    static String readLine() throws IOException {
        return br.readLine().trim();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 51ms
memory: 49952kb

input:

0.1

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 49ms
memory: 49128kb

input:

0.02

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 43ms
memory: 49352kb

input:

0.01

output:

10

result:

ok single line: '10'

Test #4:

score: 0
Accepted
time: 48ms
memory: 53428kb

input:

0.4

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 51ms
memory: 49044kb

input:

0.24

output:

3

result:

ok single line: '3'

Test #6:

score: 0
Accepted
time: 64ms
memory: 54444kb

input:

0.11

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 50ms
memory: 48796kb

input:

0.061

output:

5

result:

ok single line: '5'

Test #8:

score: 0
Accepted
time: 51ms
memory: 52936kb

input:

0.035

output:

6

result:

ok single line: '6'

Test #9:

score: 0
Accepted
time: 46ms
memory: 49336kb

input:

0.025

output:

7

result:

ok single line: '7'

Test #10:

score: 0
Accepted
time: 59ms
memory: 49992kb

input:

0.02

output:

8

result:

ok single line: '8'

Test #11:

score: 0
Accepted
time: 43ms
memory: 53568kb

input:

0.015

output:

9

result:

ok single line: '9'

Test #12:

score: 0
Accepted
time: 50ms
memory: 49408kb

input:

0.01

output:

10

result:

ok single line: '10'

Test #13:

score: 0
Accepted
time: 55ms
memory: 53360kb

input:

0.009

output:

11

result:

ok single line: '11'

Test #14:

score: 0
Accepted
time: 41ms
memory: 49360kb

input:

0.0075

output:

12

result:

ok single line: '12'

Test #15:

score: 0
Accepted
time: 40ms
memory: 53584kb

input:

0.006

output:

13

result:

ok single line: '13'

Test #16:

score: 0
Accepted
time: 54ms
memory: 50556kb

input:

0.0055

output:

14

result:

ok single line: '14'

Test #17:

score: 0
Accepted
time: 50ms
memory: 49292kb

input:

0.005

output:

15

result:

ok single line: '15'

Test #18:

score: 0
Accepted
time: 48ms
memory: 49448kb

input:

0.0033

output:

16

result:

ok single line: '16'

Test #19:

score: 0
Accepted
time: 37ms
memory: 49368kb

input:

0.001

output:

16

result:

ok single line: '16'