Counting Antibodies
Time limit1sMemory limit512 MB
Given the gene fragment counts for the kappa, lambda, and heavy chains, count how many distinct antibody molecules can be formed.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Immunoglobulins, also known as antibodies, are protein molecules. Antibodies play a major role in the immune reaction. They detect harmful foreign agents (bacteria or viruses) and help to eliminate them. Every foreign molecule binds with a unique type of antibody. There are plenty of potential harmful agents, so there should be a tremendous number of immunoglobulin types to neutralize all threats. The required number of immunoglobulin types is too large to encode each type in DNA. Luckily, there is a solution.
Immunoglobulins are produced by immune cells called B-lymphocytes, based on DNA information, namely genes. Immunoglobulin genes are assembled from DNA fragments, like a set of building blocks. Each fragment exists in several variants and is responsible for a variable region of the immunoglobulin molecule. This process is called somatic recombination.
An immunoglobulin molecule consists of two identical heavy chains and two identical light chains. There are two types of light chains with similar structure: and . Both light chain types have two variable regions, and . To form a variable region, one gene fragment is selected from multiple variants. For the light chain, the and regions select from the and variants, respectively. For the light chain, they select from the and variants, respectively.
There is only one heavy chain type, with three variable regions: , , and . To form each of them, one gene fragment is selected from the , , and variants, respectively.

You need to count how many possible immunoglobulin molecules can be produced for given values of , , , , , , and .
Input
The first line contains two integers and (), the number of gene fragment variants for the and variable regions of the light chain.
The second line contains two integers and (), the number of gene fragment variants for the and variable regions of the light chain.
The third line contains three integers , , and (), the number of gene fragment variants for the heavy chain , , and variable regions.
Output
Output one integer: the number of immunoglobulin variants that can be produced.
Hint
Somatic recombination is a powerful protective mechanism against various bacteria and viruses, but it is not the only one. Other ways to prevent foreign invasion are beyond the scope of this problem.