# 京东2017实习生真题 - 通过考试

2017-04-10

4
50 50 50 50

0.31250

C/C++语言：1000MS其它语言：3000MS

C/C++语言：65536KB其它语言：589824KB ```假设小明考了3道题,每道题成功的概率如下:

r为0,n为3,表示3道题,全错的概率;;小明如果考了三道题,则全错的概率为0.12
r\n     0       1       2       3           记录
0       1       0.6     0.24    0.12        全错
1       0       0.4     0.52    0.38        对一道题
2       0       0       0.24    0.38        对两道题
3       0       0       0       0.12        对三道题

1.首先,全错的概率:错1*错2*....错n

2.你再仔细看看上面那张表,到底有什么规律,它的奥秘将会在下面揭示

double[][] dp = new double[n + 1][n + 1];
dp = 1;
for (int i = 1; i < n + 1; i++) {
dp[i] = dp[i - 1] * (1 - p[i - 1]);
for (int j = 1; j < n + 1; j++){
dp[i][j] = dp[i - 1][j - 1]*p[i - 1]+dp[i-1][j]*(1- p[i - 1]);
}
}
-------------------------看懂的到此为止,还需要往下面看的,编程或许不适合你
-----------------------------------------------------------------

r\n     0       1
0       1       0.6
1       0       0.4

r\n     0       1       2
0       1       0.6     0.24
1       0       0.4     0.52
2       0       0       0.24

r\n     0       1       2       3
0       1       0.6     0.24    0.12
1       0       0.4     0.52    0.38
2       0       0       0.24    0.38
3       0       0       0       0.12

```import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
int n = in.nextInt();
double[] p = new double[n];
for (int i = 0; i < n; i++) p[i] = (double)in.nextInt() / 100;
double[][] dp = new double[n + 1][n + 1];
dp = 1;
for (int i = 1; i < n + 1; i++) {
dp[i] = dp[i - 1] * (1 - p[i - 1]);
for (int j = 1; j < n + 1; j++){
dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]);
}
}
double result = 0;
for (int i = (3 * n + 4) / 5; i <= n; i++) {
result += dp[n][i];
}
System.out.println(String.format("%.5f", result));
in.close();
}
}```
{"ft_lang_label":"__label__zh","ft_lang_prob":0.6971401,"math_prob":0.99965155,"size":3171,"snap":"2019-35-2019-39","text_gpt3_token_len":2449,"char_repetition_ratio":0.14872119,"word_repetition_ratio":0.25821596,"special_character_ratio":0.46862188,"punctuation_ratio":0.3305785,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9771836,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-18T10:21:30Z\",\"WARC-Record-ID\":\"<urn:uuid:ac976d64-7436-43aa-951e-da1646d6109f>\",\"Content-Length\":\"15194\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5a85405a-642c-4b9d-8c12-c6ff74161c0f>\",\"WARC-Concurrent-To\":\"<urn:uuid:a9122cb8-8888-42b2-aa70-3f6f0ffef633>\",\"WARC-IP-Address\":\"198.2.208.18\",\"WARC-Target-URI\":\"https://m.2cto.com/kf/201704/622874.html\",\"WARC-Payload-Digest\":\"sha1:OY7DJVDGKTFG3Y32IEV2JDFBUWSWFMLN\",\"WARC-Block-Digest\":\"sha1:QWMRO6XMMWOH2SJVD5Q3LMQ7TP7JVSFS\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514573264.27_warc_CC-MAIN-20190918085827-20190918111827-00072.warc.gz\"}"}