Il problema qui sotto è apparso sull'ultimo concorso di programmazione di Code Sprint 2 (è già finito). I casi base sono chiari, ma lo sviluppo di un algoritmo che risolva tutti i casi possibili è stato finora una sfida.
There are N cards on the table and each has a number between 0 and N on it. Let us denote the number on the Nth Ni. You want to pick up all the cards, but you can only pick a specific Nth card if you already picked Ni cards before. (As an example, if a card has a value of 3 on it, you can’t pick that card up unless you’ve already picked up 3 cards previously) In how many ways can all the cards be picked up?
Input are the cards with their respective numbers, and the output should be the total number of ways possible to pick them up.
Sample Input:
0 0 0
Sample Output:
6
Sample Input:
0 0 0 0
Sample Output:
24
Sample Input:
0 0 1
Sample Output
4
Sample Input:
0 3 3
Sample Output:
0