Ուղարկել | Բոլոր լուծումները | Լավագույն լուծումները | Վերադառնալ ցուցակին |
ACM_0241 - RACE CONDITION |
Vasya has written a program that launches n threads having mi instructions each.
At any point in time the CPU is executing a single instruction from a single thread. The instructions in a thread are always executed in order (switching to other threads is possible).
After all instructions in a thread have been executed, the CPU ignores this thread.
Let us define an execution path as an ordered list of actually executed instructions from different threads.
Write a program to calculate the number of different execution paths (accounting for all possible switches between threads) for a multi-threaded program.
Limitations
1≤ n ≤ 10; 1 ≤ mi ≤ 20, 1≤ i ≤ n, ∑mi ≤ 20 .
Input
The first line of the input file defines the number of threads n.
The second line contains n space-delimited integers mi, the number of instructions in the threads.
Output
The number of different execution paths.
Examples
№ |
stdin |
stdout |
1 |
2 2 2 |
6 |
2 |
3 1 2 3 |
60 |
Ավելացրեց. | Հրանտ Հովհաննիսյան |
Ամսաթիվ. | 2014-10-08 |
Ժամանակի սահմանափակումը. | 1s |
Ծրագրի տեքստի սահմանափակումը. | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Լեզուներ. | Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE |
Աղբյուրը. | Central QF 2014.C |