2017 Ali algorithm engineer Summer Internship written questions part of the interpretation of Alibaba

Source: Internet
Author: User

1. There are 7 consecutive integer balls, such as {1,2,3,4,5,6,7}, continuous extraction of three balls, if the continuous extraction of the number of 2 balls is continuous, the jackpot, the probability of winning

Pumping three consecutive balls, there are 123,234,345,456,567 five combinations, each combination has a 3*2*1=6 arrangement, any one arrangement to meet the continuous, so there are 5*6=30 kind of situation

Pumping two consecutive balls, there are 124,125,126,127,235,236,237,346,347,457

341,451,452,561,562,563,671,672,673,674

A total of 20 combinations, each combination of 6 kinds of arrangement, such as 124 have 124,142,214,241,412,421 six permutations, but 4 in the middle of the 1,2 will cause discontinuity (142,241), that is, all combinations of only 2/3 are contiguous, so a total of 20*6* (2 /3) = 80 kinds of two balls with continuous number of cases.

In comprehensive, the request = (30+80)/(7*6*5) =11/22


2. There are 12 people in an elevator, from the floor to the rise, everyone can reach the elevator to a layer to the floor of any layer out of the elevator, to the 6 floor has been no one, altogether how many kinds of elevator situation, (everyone out of the elevator can not enter, so people as the same person).


can be considered as 12 balls in the middle of the 4 plate inserted, divided into 5 parts of the problem, but the question requires two board between the number of balls can be 0, so add five ball, 17 between the ball inserted four board, the answer is C (16,4) =16*15*14*13/(4*3*2*1) = 1820 ways.


3. An Alibaba employee goes to work from 8:30 to 9:00 every day, according to the traffic jam situation about 10-30 minutes to the company, assuming he went out of time and the way time is evenly distributed, ask him to arrive before 9:00 probability


Triangular area 2*2/2=2

Parallelogram area 2*3=6, =2/6=1/3

4. The interviewer put a number on the forehead of 2 students, the numbers are positive integers, 2 students can only see each other, do not see their own, and the difference between the two figures 2, the following is the dialogue of 2 people,

A: I don't know.

B: I don't know, either.

A: I see.

B: I know, too.

Q The sum of the numbers on the head of A and B ()

A.4 b.6 c.8 d.10 e:12 f:14



Programming questions

Xiao Zhang has not been home for many years, this time home parents arranged for him many blind date girl, has a very long list, the length is N, the father is responsible for arranges the date, each randomly chooses one to Blind Date's object, the mother is responsible for the record which girl has dated, until after the date with all girls, This vast blind Date project was over, these days the parents are arguing, they will not have any verbal communication, so the father does not know which girls have dated, so the next date is likely to be a date, if Xiao Zhang to all the girls are dating, then average need to date how many girls.

Input:

Integer n,1=<n<=100000;

Output:

Returns the value of the problem description, accurate to four digits after the decimal point.

Input Sample: 1

Output Sample: 1.0000

Analysis: AI indicates the number of personal needs of the first

P (approx. i) =p (approximately to the first person | The former i-1 person has been about) = (n (i-1))/n= (n-i+1)/n

ai=1/p (approx. i individual) =n/(n-i+1)

The code is as follows

Import java.util.*;
Import Java.util.Scanner;
public class Main {public
    static void Main (string[] args) {
        Scanner scan = new Scanner (system.in);
        while (Scan.hasnext ()) {
            int N = Scan.nextint ();
            Double[] A = new double[n+1];
            Double res=0;

            for (int i=1;i<=n;i++) {
                a[i]=1.0*n/(n-i+1);
                Res+=a[i];
            }
            System.out.printf ("%.4f", res);
            System.out.println ();}}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.