Pagini: [1]   În jos
  Imprimă  
Ajutor Subiect: Movie Seating-top coder  (Citit de 2689 ori)
0 Utilizatori şi 1 Vizitator pe acest subiect.
S7012MY
Nu mai tace
*****

Karma: 26
Deconectat Deconectat

Mesaje: 648



Vezi Profilul
« : Septembrie 25, 2010, 19:43:40 »

Problem Statement
    
Elly and some of her friends (possibly none) are going to the movies. Their company consists of numFriends people, including Elly. Since they don't want to be spread across the entire hall, they decided to sit either in the same row or in the same column (though not necessarily next to one another).  Your are given a vector <string> hall representing the layout of seats in the theater that are already taken. The j-th character of the i-th element of hall will be '#' if the seat at row i, column j is already taken and '.' if it is empty.  Return the number of different ways for Elly and her friends to choose numFriends different empty seats so that their seating requirement is fulfilled. Two ways are considered different if there exists a person in their company that will sit in different seats in these two ways.

Examples
0)

    
2
{ ".#..",
  ".##.",
  "...." }
Returns: 34
Here the movie hall has 3 rows and 4 columns. The second seat in the first row is taken, as well as the seats in the middle of the second row.


De ce e 34? Eu m-am gandit ca ar trebui sa fie o suma din aranjamente(nrloclibere,nrprieteni) de pe fiecare linie si coloana
« Ultima modificare: Septembrie 25, 2010, 20:24:34 de către Trimbitas Petru » Memorat
klamathix
Echipa infoarena
Nu mai tace
*****

Karma: 733
Deconectat Deconectat

Mesaje: 1.216



Vezi Profilul
« Răspunde #1 : Septembrie 25, 2010, 21:22:56 »

Asa si este. Si suma iti da 34 pe exemplu.
Memorat
S7012MY
Nu mai tace
*****

Karma: 26
Deconectat Deconectat

Mesaje: 648



Vezi Profilul
« Răspunde #2 : Septembrie 26, 2010, 11:42:36 »

Dupa ce formula calculezi aranjamentele? Nu dupa n(n-1)(n-2)...(n-k+1). Daca calculezi asa nu da 34
Memorat
klamathix
Echipa infoarena
Nu mai tace
*****

Karma: 733
Deconectat Deconectat

Mesaje: 1.216



Vezi Profilul
« Răspunde #3 : Septembrie 26, 2010, 13:10:16 »

3 * A(3,2) ( coloana 1 si 4 , linia 1)  + 2 * A (2,2) ( linia 2 si coloana 3) + 1 * A(4,2) ( linia 3) =
3 * 6 + 2 * 2 + 1 * 12=
34.
Memorat
Pagini: [1]   În sus
  Imprimă  
 
Schimbă forumul:  

Powered by SMF 1.1.19 | SMF © 2006-2013, Simple Machines