Problem J
Invoker (Hard)
You are an Arch-Magus Invoker, one of the strongest sorcerers that is able to command sources of magic.
The difference between an Arch-Magus Invoker and a regular Invoker is that an Arch-Magus holds an advanced degree or is pursuing a post-doc in mathemagical studies at the Institute of Arcane Studies.
Magical Training
There are two sources of magic available to invokers to
control,
As an invoker you have the choice of combining two sources
of magic (denoted
The rules for combining sources is as follows:
-
Combining a source of Reagus or Imagus with another source of equal type creates the same type but you add the potencies.
-
-
Combining a source of Reagus and Imagus together creates a new complex form of magic.
-
Casting sources of magic has some different laws:
-
Casting Reagus on to Reagus creates a source of Reagus whose potency is the product of the previous sources.
-
-
Casting Imagus on to another source of Imagus creates anti-Reagus (negative potency) with a potency of the product of the two sources.
-
-
Casting Reagus on Imagus or Imagus on Reagus creates Imagus with a potency of the product of the two sources.
-
Additionally, every magic source
Casting a complex magic source on its complement (or visa versa), generates a non-negative number known as the potency norm of the source.
Advanced Mathemagic!!
As an Arch-Magus you are well studied in an additional
source of magic:
Jae acts like Imagus when near the presence of Reagus.
However, when Jae is cast on Imagus it can form a
Casting either form of Imagus, Jae, or Kaos on itself creates anti-Reagus.
Casting Imagus on to Jae actually creates anti-Kaos however
The complete casting table between the four elements is as follows:
The same rules for combination exist for Jae and Kaos as they do for Imagus.
If you haven’t noticed, this means that casting is non-commutative. That is:
where
Complex combinations and castings are allowed such as:
Casting is distributive, which means
For every source there is also guaranteed to exist an inverse source that when cast will neutralize the magical energies.
where
Complements for Jae and Kaos work the same way they do for Imagus.
Problem
You are currently locked in battle against an equally
powerful foe. You recognize that you can defeat them by
neutralizing their source of magic. That is, you cast a spell
on them that will turn their source into the neutral source
However, magic is not without its consequences. Any source you cast on your opponent will also be cast on you as well, changing your current magical source.
When you cast a spell on your opponent (and simultaneously on yourself) the magical cast is a right cast (described above), that is:
where
When the dust settles and you are declared victorious, what is your new magical source?
Input
The inputs are two magical sources separated by new lines.
The first line contains your source:
All sources are integers in the range
Output
Output your resulting source after you have annihilated your
opponent. The output should be four space separated values
Your answers will be accepted if they have an absolute or
relative error of at most
Sample Input 1 | Sample Output 1 |
---|---|
1 2 3 4 1 2 3 4 |
1.0 0.0 0.0 0.0 |
Sample Input 2 | Sample Output 2 |
---|---|
0 1 0 0 0 0 1 0 |
0.0 0.0 0.0 -1.0 |