The Navy Problem
All submissions for this problem are available.
The US Navy has 10 aircraft carriers serving its seas at the moment and there are only 12 aircraft carrier certified Navy Captains. The Navy keeps 10 Captains in active service and 2 in planning service at a point of time to ensure respite for their officers. In a bid to improve the versatility of the Captains with the Ship Crew, the Navy decides to carry an exercise by regularly transferring their active Captains amongst the ships to ensure war time flexibility of their Captains. The Navy hires a Maritime Consultancy Company to keep log of their ongoing experiment. The Consultancy Company soon realizes, according to navy standards, that only a few Captains work effectively with a Ship's Crew. They chart out a table which denotes the ability of a Captain to work with a Ship's Crew, where 1 denotes success at maintaining standards and 0 denotes otherwise, where 0 and 1 are the effectiveness of a Captain with a Ship.
|Ship 1||Ship 2||Ship 3||Ship 4||Ship 5||Ship 6||Ship 7||Ship 8||Ship 9||Ship 10|
The US Navy decides, that at the time of war, they would keep transferring the selected 10 Captains from one ship to another, such that all possible ship-captain combinations are covered. For a given ship-captain combination, the function given below calculates the effectiveness index for that combination. The Consultancy Company has to add all such effective indices covering all possible permutations and give the US Army the net effectiveness factor.
Input for function X : List of Active Captains Function Definition: Effectiveness of Captain of Ship 1 && Effectiveness of Captain of Ship 2 + Effectiveness of Captain of Ship 3 || Effectiveness of Captain of Ship 4 + Effectiveness of Captain of Ship 5 && Effectiveness of Captain of Ship 6 + Effectiveness of Captain of Ship 7 || Effectiveness of Captain of Ship 8 + Effectiveness of Captain of Ship 9 XOR Effectiveness of Captain of Ship 10 = Effectiveness Index Output for function X : Effectiveness Index Note: && (AND), || (OR) and XOR are Boolean Operators.
Your task is to write a program to calculate the net effectiveness index considering all possible ship-Captain combinations, given a list of the ten active Captains.
The first line will consist of a number of test cases N.
Each test case consists of one line stating the selected 10 Captains.
The output contains N lines corresponding to each test case.
Each line states the total effectiveness index calculated after considering all ship-Captain combinations.
ExampleInput: 2 BCDEFGHIJK EHIJABLGCK Output: 9233280 8830080
First line of input indicates that there are 2 test cases.
Next line gives the list of 10 Captains selected as first test case and second line gives list of 10 Captains
selected as second test case.
First line of the output is the sum of the effectiveness index for all possible permutations of BCDEFGHIJK.
Similarly, second line of the output is the sum of the effectiveness index for all possible permutations of EHIJABLGCK.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.